結果

問題 No.1666 累乗数
ユーザー siro53siro53
提出日時 2021-09-04 00:10:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,455 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2023-08-22 02:44:37
合計ジャッジ時間 21,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
77,432 KB
testcase_01 AC 701 ms
78,088 KB
testcase_02 AC 693 ms
78,228 KB
testcase_03 AC 693 ms
78,036 KB
testcase_04 AC 700 ms
78,100 KB
testcase_05 AC 1,455 ms
78,024 KB
testcase_06 AC 1,444 ms
77,856 KB
testcase_07 AC 1,442 ms
78,072 KB
testcase_08 AC 1,437 ms
77,744 KB
testcase_09 AC 796 ms
78,152 KB
testcase_10 AC 786 ms
78,188 KB
testcase_11 AC 798 ms
77,952 KB
testcase_12 AC 780 ms
77,836 KB
testcase_13 AC 1,247 ms
78,548 KB
testcase_14 AC 1,248 ms
78,196 KB
testcase_15 AC 1,252 ms
78,848 KB
testcase_16 AC 1,224 ms
78,260 KB
testcase_17 AC 918 ms
78,508 KB
testcase_18 AC 1,049 ms
78,520 KB
testcase_19 AC 920 ms
78,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import sqrt
input = sys.stdin.readline

limit = [0] * 60
for i in range(2, 60):
    C = 10**18
    ok, ng = 0, 10**9 + 10
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if mid**i <= C:
            ok = mid
        else:
            ng = mid
    limit[i] = ok + 2

def f(N):
    cnt = [0] * 60
    for i in range(2, 60)[::-1]:
        ok = 0
        ng = limit[i]
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if mid ** i <= N:
                ok = mid
            else:
                ng = mid
        ok -= 1
        cnt[i] = ok - sum(cnt[::i])
    return sum(cnt) + 1

# print(f(10))

def main():
    K = int(input())
    ok, ng = 10**18, 0 
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if f(mid) >= K:
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    T = int(input())
    for _ in range(T):
        main()
0