結果

問題 No.1666 累乗数
ユーザー lloyzlloyz
提出日時 2022-01-23 15:15:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 648 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 79,164 KB
最終ジャッジ日時 2023-08-19 20:16:02
合計ジャッジ時間 12,840 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
77,212 KB
testcase_01 AC 592 ms
77,916 KB
testcase_02 AC 596 ms
78,896 KB
testcase_03 AC 589 ms
78,384 KB
testcase_04 AC 587 ms
78,932 KB
testcase_05 AC 513 ms
78,584 KB
testcase_06 AC 520 ms
78,484 KB
testcase_07 AC 513 ms
78,148 KB
testcase_08 AC 513 ms
78,284 KB
testcase_09 AC 562 ms
78,304 KB
testcase_10 AC 571 ms
78,156 KB
testcase_11 AC 569 ms
78,320 KB
testcase_12 AC 574 ms
79,140 KB
testcase_13 AC 539 ms
78,240 KB
testcase_14 AC 537 ms
79,164 KB
testcase_15 AC 529 ms
78,116 KB
testcase_16 AC 541 ms
77,976 KB
testcase_17 AC 558 ms
78,036 KB
testcase_18 AC 648 ms
78,288 KB
testcase_19 AC 556 ms
78,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Limit = [0 for _ in range(60)]
for i in range(2, 60):
    Limit[i] = int((10**18 + 10000)**(1 / i))

def f(n):
    Cnt = [0 for _ in range(60)]
    for i in range(59, 1, -1):
        left = 0
        right = Limit[i] + 1
        while right - left > 1:
            mid = (left + right) // 2
            if mid**i <= n:
                left = mid
            else:
                right = mid
        left -= 1
        Cnt[i] = left - sum(Cnt[::i])
    return sum(Cnt) + 1

t = int(input())
for _ in range(t):
    k = int(input())
    left = 0
    right = 10**18
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) >= k:
            right = mid
        else:
            left = mid
    print(right)
0