結果

問題 No.1666 累乗数
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-09-03 22:25:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,908 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 77,368 KB
最終ジャッジ日時 2024-12-15 14:32:13
合計ジャッジ時間 30,260 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
76,036 KB
testcase_01 AC 1,221 ms
76,812 KB
testcase_02 AC 1,180 ms
77,160 KB
testcase_03 AC 1,179 ms
77,368 KB
testcase_04 AC 1,179 ms
77,068 KB
testcase_05 AC 1,874 ms
77,108 KB
testcase_06 AC 1,872 ms
77,128 KB
testcase_07 AC 1,908 ms
77,092 KB
testcase_08 AC 1,882 ms
77,124 KB
testcase_09 AC 1,309 ms
76,476 KB
testcase_10 AC 1,311 ms
76,612 KB
testcase_11 AC 1,315 ms
77,068 KB
testcase_12 AC 1,316 ms
76,788 KB
testcase_13 AC 1,777 ms
77,092 KB
testcase_14 AC 1,781 ms
76,876 KB
testcase_15 AC 1,781 ms
77,136 KB
testcase_16 AC 1,770 ms
77,240 KB
testcase_17 AC 1,469 ms
76,580 KB
testcase_18 AC 1,504 ms
77,012 KB
testcase_19 AC 1,444 ms
77,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline #文字列入力はするな!!
from math import log

def f(x):
    if x==0:return 0
    g=[0]*62
    res=1
    for b in range(2,62):
        a=int(x**(1/b))
        while (a+1)**b<=x:
            a+=1
        while a**b>x:a-=1
        if a>=2:g[b]=a-1
    for b in range(61,1,-1):
        for c in range(b+1,62):
            if c%b==0:
                g[b]-=g[c]
        res+=g[b]
    return res

T=int(input())
for _ in range(T):
    k=int(input())
    ok=10**18+100
    ng=0
    while ok-ng>1:
        mid=(ok+ng)//2
        if f(mid)>=k:ok=mid
        else:ng=mid
    print(ok)

0