fakeofakeov's blog

By fakeofakeov, history, 13 days ago,

Last week I found a difficult problem. In standard input there are two numbers A and B. I need to output sum A + B. I solve this problem

A, B = map(int, input().split())
ANS = 0
for i in range(A):
ANS += 1
for i in range(B):
ANS += 1
print(ANS)


But then I found more difficult problem. In this problem A can be < 0. Please help me with this difficult problem. upd: Now I know how to solve this problem, but it works very slow. I have heard about solution O(B). Does anybody know it?

• -19

 » 13 days ago, # |   0 if A<0 then add -1 xD
•  » » 13 days ago, # ^ |   0 Thanks, now it works, but I have TL on some tests. Can you help with it?
•  » » » 13 days ago, # ^ |   +24 You can use FFT for faster results.
•  » » » 11 days ago, # ^ | ← Rev. 2 →   0 https://github.com/crackersamdjam/Templates/pull/19 This method uses recursive and binary operations for computing additive summative sums with a fast Big O (pronounced Big-Oh (pronounced Big-Ohh)) time complexity.