N = int(input())
l = 1
h = 10**100
r = -1
while l <= h:
m = (l + h) // 2
if m * (m-1) // 2 + 1 <= N:
r = m
l = m + 1
else:
h = m - 1
print(2*N-r)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3428 KB |
Output is correct |
2 |
Correct |
26 ms |
3300 KB |
Output is correct |
3 |
Correct |
25 ms |
3300 KB |
Output is correct |
4 |
Correct |
26 ms |
3272 KB |
Output is correct |
5 |
Correct |
25 ms |
3300 KB |
Output is correct |
6 |
Correct |
26 ms |
3300 KB |
Output is correct |
7 |
Correct |
25 ms |
3300 KB |
Output is correct |
8 |
Correct |
25 ms |
3300 KB |
Output is correct |
9 |
Correct |
25 ms |
3300 KB |
Output is correct |
10 |
Correct |
24 ms |
3300 KB |
Output is correct |
11 |
Correct |
25 ms |
3304 KB |
Output is correct |
12 |
Correct |
25 ms |
3300 KB |
Output is correct |
13 |
Correct |
26 ms |
3300 KB |
Output is correct |
14 |
Correct |
25 ms |
3324 KB |
Output is correct |
15 |
Correct |
25 ms |
3300 KB |
Output is correct |
16 |
Correct |
25 ms |
3404 KB |
Output is correct |
17 |
Correct |
24 ms |
3172 KB |
Output is correct |
18 |
Correct |
25 ms |
3300 KB |
Output is correct |
19 |
Correct |
25 ms |
3300 KB |
Output is correct |
20 |
Correct |
25 ms |
3300 KB |
Output is correct |
21 |
Correct |
26 ms |
3300 KB |
Output is correct |
22 |
Correct |
26 ms |
3300 KB |
Output is correct |