結果

問題 No.1666 累乗数
ユーザー tassei903tassei903
提出日時 2021-09-03 23:04:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 77,744 KB
最終ジャッジ日時 2024-05-09 06:33:40
合計ジャッジ時間 6,960 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
76,360 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
p = []
MAX = 63
arr = [-1] * (MAX + 1)
for i in range(2, int(MAX**0.5)+1):
    if arr[i]!=-1:
        continue
    j = 1
    p.append(i)
    while i * j < len(arr):
        if arr[i * j] < 0:
            arr[i * j] = i
        j += 1
for i in range(2, len(arr)):
    if arr[i]==-1:
        p.append(i)

def g(x,n):
    ng = 10**9
    ok = 0
    while ng-ok>1:
        d = (ok+ng)//2
        if d**x<=n:
            ok = d
        else:
            ng = d
    return ok

def g(x,n):
    c = int(n**(1/x))-2
    return max([i for i in range(c,c+4) if pow(i,x)<=n])

def f(x):
    r = 1
    for q in p:
        if pow(2,q)>x:
            break
        elif pow(3,q)>x:
            r+=1
            continue
        r+=g(q,x)-1
    #print(x,r)
    return r>=K


T = ni()
for i in range(T):
    K = ni()
    ok = 10**18
    ng = 0
    while ok-ng>1:
        d = (ok+ng)//2
        if f(d):
            ok = d
        else:
            ng = d
    print(ok)
0