제출 #885971

#제출 시각아이디문제언어결과실행 시간메모리
885971karimov홀-짝 수열 (IZhO11_oddeven)Pypy 3
0 / 100
28 ms18284 KiB
import math
n = float(input())
x = math.ceil((math.sqrt(8 * n + 1) - 1) / 2)
if x % 2 == 1:
    d = (x + 1) // 2 - 1
    x -= 1
    result = (d ** 2 * 4 + 1) + (2 * (n - (x * (x + 1) // 2) - 1))
else:
    d = x // 2 - 1
    x -= 1
    result = (d ** 2 * 4 + 4 * d + 2) + (2 * (n - (x * (x + 1) // 2) - 1))
print(int(result))
#Verdict Execution timeMemoryGrader output
Fetching results...