답안 #676517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676517 2022-12-31T06:04:57 Z QwertyPi 홀-짝 수열 (IZhO11_oddeven) Python 3
100 / 100
16 ms 2908 KB
from math import sqrt
n = int(input())

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x


x = isqrt(n * 2)

while x * (x - 1) // 2 >= n:
    x -= 1
while x * (x + 1) // 2 < n:
    x += 1
print(n * 2 - x)
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 14 ms 2740 KB Output is correct
3 Correct 13 ms 2756 KB Output is correct
4 Correct 14 ms 2772 KB Output is correct
5 Correct 13 ms 2784 KB Output is correct
6 Correct 16 ms 2772 KB Output is correct
7 Correct 13 ms 2788 KB Output is correct
8 Correct 13 ms 2848 KB Output is correct
9 Correct 13 ms 2732 KB Output is correct
10 Correct 15 ms 2848 KB Output is correct
11 Correct 15 ms 2748 KB Output is correct
12 Correct 13 ms 2908 KB Output is correct
13 Correct 13 ms 2772 KB Output is correct
14 Correct 12 ms 2772 KB Output is correct
15 Correct 13 ms 2772 KB Output is correct
16 Correct 13 ms 2792 KB Output is correct
17 Correct 13 ms 2832 KB Output is correct
18 Correct 12 ms 2772 KB Output is correct
19 Correct 14 ms 2836 KB Output is correct
20 Correct 13 ms 2844 KB Output is correct
21 Correct 13 ms 2772 KB Output is correct
22 Correct 14 ms 2780 KB Output is correct