import math
def solve(n):
n = int(n)
m = math.isqrt(2 * n) - 5
while m <= -1 or (m + 1) * (m + 2) // 2 < n:
m = m + 1
a = m * (m + 1) // 2 + m * (m - 1) // 2
b = n - m * (m + 1) // 2
ans = a + 2 * b - 1
return ans
print(solve(input()))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2764 KB |
Output is correct |
2 |
Correct |
14 ms |
2804 KB |
Output is correct |
3 |
Correct |
15 ms |
2780 KB |
Output is correct |
4 |
Correct |
14 ms |
2840 KB |
Output is correct |
5 |
Correct |
16 ms |
2844 KB |
Output is correct |
6 |
Correct |
14 ms |
2840 KB |
Output is correct |
7 |
Correct |
14 ms |
2844 KB |
Output is correct |
8 |
Correct |
13 ms |
2764 KB |
Output is correct |
9 |
Correct |
15 ms |
2764 KB |
Output is correct |
10 |
Correct |
14 ms |
2740 KB |
Output is correct |
11 |
Correct |
12 ms |
2840 KB |
Output is correct |
12 |
Correct |
14 ms |
2844 KB |
Output is correct |
13 |
Correct |
13 ms |
2800 KB |
Output is correct |
14 |
Correct |
13 ms |
2840 KB |
Output is correct |
15 |
Correct |
12 ms |
2740 KB |
Output is correct |
16 |
Correct |
13 ms |
2764 KB |
Output is correct |
17 |
Correct |
13 ms |
2764 KB |
Output is correct |
18 |
Correct |
13 ms |
2764 KB |
Output is correct |
19 |
Correct |
14 ms |
2892 KB |
Output is correct |
20 |
Correct |
13 ms |
2764 KB |
Output is correct |
21 |
Correct |
12 ms |
2840 KB |
Output is correct |
22 |
Correct |
14 ms |
2768 KB |
Output is correct |