n=int(input());
l=1;
r=10**100
while l < r:
mid = (l+r)//2
x = (1+mid)*(mid)//2
if x >= n:
r=mid
else:
l=mid+1
x=(1+r)*r//2
print(r*r - 2*(x-n))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
18208 KB |
Output is correct |
2 |
Correct |
38 ms |
18264 KB |
Output is correct |
3 |
Correct |
33 ms |
18228 KB |
Output is correct |
4 |
Correct |
34 ms |
18212 KB |
Output is correct |
5 |
Correct |
33 ms |
18212 KB |
Output is correct |
6 |
Correct |
34 ms |
18228 KB |
Output is correct |
7 |
Correct |
34 ms |
18172 KB |
Output is correct |
8 |
Correct |
33 ms |
18116 KB |
Output is correct |
9 |
Correct |
33 ms |
18244 KB |
Output is correct |
10 |
Correct |
36 ms |
18220 KB |
Output is correct |
11 |
Correct |
39 ms |
18244 KB |
Output is correct |
12 |
Correct |
34 ms |
18124 KB |
Output is correct |
13 |
Correct |
33 ms |
18184 KB |
Output is correct |
14 |
Correct |
33 ms |
18220 KB |
Output is correct |
15 |
Correct |
34 ms |
18164 KB |
Output is correct |
16 |
Correct |
33 ms |
18116 KB |
Output is correct |
17 |
Correct |
34 ms |
18176 KB |
Output is correct |
18 |
Correct |
34 ms |
18120 KB |
Output is correct |
19 |
Correct |
34 ms |
18188 KB |
Output is correct |
20 |
Correct |
33 ms |
18220 KB |
Output is correct |
21 |
Correct |
34 ms |
18132 KB |
Output is correct |
22 |
Correct |
34 ms |
18116 KB |
Output is correct |