Submission #337868

#TimeUsernameProblemLanguageResultExecution timeMemory
337868talant117408Odd-even (IZhO11_oddeven)Cpython 3
100 / 100
18 ms3052 KiB
import math n = input() n = int(n) def calc(x): return x*(x+1)//2 l = 1 r = 1e51 while l < r: mid = int((l+r+1)//2) if calc(mid) <= int(n): l = mid else: r = mid-1 l = int(l) if calc(l) == n: print(int(int(n*2)-int(l))) else: print(int(int(n*2)-int(l)-1))
#Verdict Execution timeMemoryGrader output
Fetching results...