結果

問題 No.1666 累乗数
ユーザー googol_S0googol_S0
提出日時 2021-09-03 21:49:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 86,348 KB
最終ジャッジ日時 2024-05-09 03:15:02
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
81,408 KB
testcase_01 AC 148 ms
86,016 KB
testcase_02 AC 148 ms
85,840 KB
testcase_03 AC 143 ms
85,888 KB
testcase_04 AC 146 ms
85,892 KB
testcase_05 AC 134 ms
85,956 KB
testcase_06 AC 140 ms
85,888 KB
testcase_07 AC 140 ms
85,852 KB
testcase_08 AC 136 ms
86,040 KB
testcase_09 AC 164 ms
86,172 KB
testcase_10 AC 156 ms
86,016 KB
testcase_11 AC 160 ms
85,780 KB
testcase_12 AC 164 ms
86,272 KB
testcase_13 AC 167 ms
86,348 KB
testcase_14 AC 166 ms
86,016 KB
testcase_15 AC 170 ms
85,756 KB
testcase_16 AC 164 ms
85,888 KB
testcase_17 AC 166 ms
85,760 KB
testcase_18 AC 167 ms
85,888 KB
testcase_19 AC 155 ms
85,888 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