# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019665 | Minbaev | Odd-even (IZhO11_oddeven) | Cpython 3 | 11 ms | 2988 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
def binpow(a, b, mod=1e9 + 7):
if b == 0:
return 1
if b % 2 == 0:
c = binpow(a, b // 2, mod)
return (c * c) % mod
return (binpow(a, b - 1, mod) * a) % mod
def divi(a, b, mod=1e9 + 7):
return (a * binpow(b, mod - 2, mod)) % mod
def solve():
n = int(input())
l = 1
r = 1e51
ans = -1
while l <= r:
mid = (l + r) // 2
sum = mid * (mid + 1) // 2
if sum >= n:
ans = mid
r = mid - 1
else:
l = mid + 1
val = 0
val = int(((ans * (ans + 1) // 2) - ans) * 2 + (ans - 1) + 1 - (ans * (ans + 1) // 2 - n) * 2)
print(val)
if __name__ == "__main__":
tt = 1
# tt = int(input())
while tt:
solve()
tt -= 1
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |