結果

問題 No.1666 累乗数
ユーザー Kiri8128Kiri8128
提出日時 2021-09-03 22:59:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 737 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 82,560 KB
最終ジャッジ日時 2024-05-09 06:19:18
合計ジャッジ時間 8,491 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
81,664 KB
testcase_01 AC 1,045 ms
76,928 KB
testcase_02 AC 1,084 ms
77,184 KB
testcase_03 AC 1,041 ms
76,928 KB
testcase_04 AC 1,046 ms
77,056 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def sqrt(n, k = 2):
    if n == 0: return 0
    l = k - 1
    if not n: return 0
    y = 1 << (n.bit_length() + l) // k
    x = y + 1
    while y < x:
        x = y
        y = (l * x + n // (x ** l)) // k
    return x
def cnt(n):
    s = 1
    for b in range(2, 61):
        s += W[b] * (sqrt(n, b) - 1)
    return s
    
W = [0, 0, 1, 1, 0, 1, -1, 1, 0, 0, -1, 1, 0, 1, -1, -1, 0, 1, 0, 1, 0, -1, -1, 1, 0, 0, -1, 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, 0, -1, 1, 0, 0, 0, -1, 0, 1, 0, -1, 0, -1, -1, 1, 0]
T = int(input())
for _ in range(T):
    K = int(input())
    l, r = 0, 10 ** 18
    while r - l > 1:
        m = l + r >> 1
        if cnt(m) < K:
            l = m
        else:
            r = m
    print(r)
0