結果

問題 No.1666 累乗数
ユーザー 👑 rin204rin204
提出日時 2023-12-20 22:50:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 909 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 81,272 KB
最終ジャッジ日時 2023-12-20 22:50:21
合計ジャッジ時間 11,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
68,736 KB
testcase_01 AC 135 ms
76,484 KB
testcase_02 AC 151 ms
76,788 KB
testcase_03 AC 157 ms
76,616 KB
testcase_04 AC 153 ms
76,852 KB
testcase_05 AC 678 ms
79,196 KB
testcase_06 AC 700 ms
79,196 KB
testcase_07 AC 678 ms
79,580 KB
testcase_08 AC 706 ms
79,452 KB
testcase_09 AC 296 ms
78,248 KB
testcase_10 AC 365 ms
78,468 KB
testcase_11 AC 374 ms
78,984 KB
testcase_12 AC 363 ms
78,608 KB
testcase_13 AC 909 ms
81,252 KB
testcase_14 AC 882 ms
80,860 KB
testcase_15 AC 870 ms
81,272 KB
testcase_16 AC 899 ms
80,864 KB
testcase_17 AC 470 ms
79,472 KB
testcase_18 AC 670 ms
80,136 KB
testcase_19 AC 526 ms
79,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = 60

memo = {}


def f(m):
    if m in memo:
        return memo[m]
    cnt = 0
    C = [0] * (M + 1)
    for i in range(M, 1, -1):
        c = int(m ** (1 / i))
        if c**i <= m:
            c += 1
        if c**i > m:
            c -= 1
        c -= 1
        C[i] = c
        for j in range(2 * i, M + 1, i):
            if j % i == 0:
                C[i] -= C[j]
        cnt += C[i]
    memo[m] = cnt
    return cnt


for _ in range(int(input())):
    k = int(input())
    if k == 1:
        print(1)
        continue

    k -= 1
    l = 1
    r = 10**18
    while r - l > 1:
        m = (l + r) // 2
        if f(m) >= k:
            r = m
        else:
            l = m
    print(r)
0