結果

問題 No.1666 累乗数
ユーザー titiatitia
提出日時 2021-09-04 01:03:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 971 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 294,088 KB
最終ジャッジ日時 2023-08-22 03:49:39
合計ジャッジ時間 21,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 897 ms
291,096 KB
testcase_01 AC 959 ms
293,388 KB
testcase_02 AC 948 ms
293,380 KB
testcase_03 AC 943 ms
293,460 KB
testcase_04 AC 953 ms
294,088 KB
testcase_05 AC 947 ms
293,988 KB
testcase_06 AC 939 ms
293,308 KB
testcase_07 AC 947 ms
293,556 KB
testcase_08 AC 960 ms
293,544 KB
testcase_09 AC 971 ms
293,452 KB
testcase_10 AC 944 ms
293,472 KB
testcase_11 AC 939 ms
293,956 KB
testcase_12 AC 945 ms
293,504 KB
testcase_13 AC 963 ms
293,488 KB
testcase_14 AC 947 ms
293,568 KB
testcase_15 AC 949 ms
293,572 KB
testcase_16 AC 944 ms
293,428 KB
testcase_17 AC 941 ms
293,868 KB
testcase_18 AC 950 ms
293,924 KB
testcase_19 AC 942 ms
293,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0