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 |
24 ms |
3404 KB |
Output is correct |
2 |
Correct |
32 ms |
3308 KB |
Output is correct |
3 |
Correct |
22 ms |
3300 KB |
Output is correct |
4 |
Correct |
24 ms |
3308 KB |
Output is correct |
5 |
Correct |
22 ms |
3300 KB |
Output is correct |
6 |
Correct |
21 ms |
3308 KB |
Output is correct |
7 |
Correct |
24 ms |
3240 KB |
Output is correct |
8 |
Correct |
21 ms |
3308 KB |
Output is correct |
9 |
Correct |
23 ms |
3320 KB |
Output is correct |
10 |
Correct |
33 ms |
3300 KB |
Output is correct |
11 |
Correct |
23 ms |
3308 KB |
Output is correct |
12 |
Correct |
26 ms |
3308 KB |
Output is correct |
13 |
Correct |
24 ms |
3308 KB |
Output is correct |
14 |
Correct |
25 ms |
3308 KB |
Output is correct |
15 |
Correct |
30 ms |
3300 KB |
Output is correct |
16 |
Correct |
24 ms |
3308 KB |
Output is correct |
17 |
Correct |
26 ms |
3308 KB |
Output is correct |
18 |
Correct |
26 ms |
3300 KB |
Output is correct |
19 |
Correct |
32 ms |
3308 KB |
Output is correct |
20 |
Correct |
27 ms |
3308 KB |
Output is correct |
21 |
Correct |
28 ms |
3300 KB |
Output is correct |
22 |
Correct |
26 ms |
3308 KB |
Output is correct |