n=int(input())
l = 1; r = 10**51; best = 0
while l <= r:
mid = ( l + r ) // 2
if mid * ( mid + 1) // 2 >= n:
best = mid
r = mid - 1
else: l = mid + 1
print( 2 * n - best )
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
19248 KB |
Output is correct |
2 |
Correct |
22 ms |
19260 KB |
Output is correct |
3 |
Correct |
21 ms |
19268 KB |
Output is correct |
4 |
Correct |
22 ms |
19260 KB |
Output is correct |
5 |
Correct |
22 ms |
19260 KB |
Output is correct |
6 |
Correct |
22 ms |
19260 KB |
Output is correct |
7 |
Correct |
23 ms |
19432 KB |
Output is correct |
8 |
Correct |
22 ms |
19212 KB |
Output is correct |
9 |
Correct |
21 ms |
19328 KB |
Output is correct |
10 |
Correct |
21 ms |
19300 KB |
Output is correct |
11 |
Correct |
22 ms |
19260 KB |
Output is correct |
12 |
Correct |
21 ms |
19260 KB |
Output is correct |
13 |
Correct |
22 ms |
19424 KB |
Output is correct |
14 |
Correct |
23 ms |
19260 KB |
Output is correct |
15 |
Correct |
29 ms |
19260 KB |
Output is correct |
16 |
Correct |
21 ms |
19260 KB |
Output is correct |
17 |
Correct |
22 ms |
19260 KB |
Output is correct |
18 |
Correct |
20 ms |
19260 KB |
Output is correct |
19 |
Correct |
20 ms |
19260 KB |
Output is correct |
20 |
Correct |
21 ms |
19384 KB |
Output is correct |
21 |
Correct |
21 ms |
19256 KB |
Output is correct |
22 |
Correct |
20 ms |
19260 KB |
Output is correct |