from math import sqrt
n = int(input())
x = int(sqrt(n * 2))
while x * (x - 1) // 2 >= n:
x -= 1
while x * (x + 1) / 2 < n:
x += 1
print(n * 2 - x)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
2724 KB |
Output is correct |
2 |
Correct |
13 ms |
2836 KB |
Output is correct |
3 |
Correct |
12 ms |
2820 KB |
Output is correct |
4 |
Correct |
13 ms |
2776 KB |
Output is correct |
5 |
Correct |
13 ms |
2752 KB |
Output is correct |
6 |
Correct |
13 ms |
2832 KB |
Output is correct |
7 |
Correct |
16 ms |
2832 KB |
Output is correct |
8 |
Correct |
13 ms |
2772 KB |
Output is correct |
9 |
Correct |
12 ms |
2836 KB |
Output is correct |
10 |
Correct |
13 ms |
2772 KB |
Output is correct |
11 |
Correct |
14 ms |
2828 KB |
Output is correct |
12 |
Correct |
16 ms |
2732 KB |
Output is correct |
13 |
Correct |
12 ms |
2772 KB |
Output is correct |
14 |
Correct |
16 ms |
2832 KB |
Output is correct |
15 |
Execution timed out |
2063 ms |
2740 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |