結果

問題 No.1666 累乗数
ユーザー googol_S0googol_S0
提出日時 2021-09-03 21:49:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 87,140 KB
最終ジャッジ日時 2023-08-21 21:09:25
合計ジャッジ時間 5,194 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
86,332 KB
testcase_01 AC 208 ms
87,008 KB
testcase_02 AC 181 ms
87,028 KB
testcase_03 AC 180 ms
87,048 KB
testcase_04 AC 177 ms
86,936 KB
testcase_05 AC 168 ms
87,080 KB
testcase_06 AC 172 ms
86,924 KB
testcase_07 AC 172 ms
87,140 KB
testcase_08 AC 169 ms
86,800 KB
testcase_09 AC 198 ms
86,884 KB
testcase_10 AC 191 ms
87,088 KB
testcase_11 AC 191 ms
87,032 KB
testcase_12 AC 199 ms
86,880 KB
testcase_13 AC 202 ms
87,112 KB
testcase_14 AC 201 ms
86,956 KB
testcase_15 AC 205 ms
87,032 KB
testcase_16 AC 199 ms
87,132 KB
testcase_17 AC 200 ms
86,980 KB
testcase_18 AC 201 ms
87,112 KB
testcase_19 AC 190 ms
86,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X,Y,Z=set(),set(),set()
INF=10**18
for i in range(4,62):
  j=1
  while (j**i)<=INF:
    X.add(j**i)
    if i%2==0:
      Y.add(j**i)
    if i%3==0:
      Z.add(j**i)
    j+=1
X=sorted(X)
Y=sorted(Y)
Z=sorted(Z)
from bisect import *
for t in range(int(input())):
  K=int(input())
  L,R=0,INF
  while L<R:
    M=(L+R+1)>>1
    A=bisect_right(X,M)
    x=int(M**0.5)
    for i in range(x-2,x+2):
      if i>=0 and (i+1)*(i+1)>M:
        x=i
        break
    A+=x
    A-=bisect_right(Y,M)
    x=int(M**(1/3))
    for i in range(x-2,x+2):
      if i>=0 and (i+1)*(i+1)*(i+1)>M:
        x=i
        break
    A+=x
    A-=bisect_right(Z,M)
    if A<K:
      L=M
    else:
      R=min(R-1,M)
  print(L+1)
0