n = int(input())
l, r, best = 1, 2 * 10 ** 9, -1
while l <= r:
m = (l + r) // 2
if m * (m + 1) // 2 >= n:
best = m
r = m - 1
else:
l = m + 1
print(2 * n - best)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
2908 KB |
Output is correct |
2 |
Correct |
10 ms |
2908 KB |
Output is correct |
3 |
Correct |
10 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
2908 KB |
Output is correct |
5 |
Correct |
10 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
2956 KB |
Output is correct |
7 |
Correct |
10 ms |
2908 KB |
Output is correct |
8 |
Correct |
10 ms |
2908 KB |
Output is correct |
9 |
Correct |
11 ms |
2908 KB |
Output is correct |
10 |
Correct |
10 ms |
2908 KB |
Output is correct |
11 |
Correct |
10 ms |
2808 KB |
Output is correct |
12 |
Correct |
10 ms |
2908 KB |
Output is correct |
13 |
Incorrect |
10 ms |
2908 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |