結果
問題 |
No.1666 累乗数
|
ユーザー |
![]() |
提出日時 | 2021-09-04 01:03:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 899 ms / 2,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 82,008 KB |
実行使用メモリ | 314,944 KB |
最終ジャッジ日時 | 2024-12-15 21:33:25 |
合計ジャッジ時間 | 18,151 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
import sys input = sys.stdin.readline import bisect S=[] for p in range(3,65): for i in range(1,10**6+5): S.append(i**p) if i**p>10**18: break S=sorted(set(S)) T=[] for s in S: r=int(s**(1/2)) if r**2==s or (r+1)**2==s or (r-1)**2==s: continue T.append(s) def calc(x): if x==1: return 1 y=int(x**(1/2)) while y*y>x: y-=1 k=bisect.bisect(T,x) return y+k t=int(input()) for tests in range(t): n=int(input()) OK=10**18 NG=0 while OK>NG+1: mid=(OK+NG)//2 #print(mid,calc(mid)) if calc(mid)>=n: OK=mid else: NG=mid print(OK)