結果

問題 No.1666 累乗数
ユーザー asumo0729asumo0729
提出日時 2021-09-14 21:38:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 597 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 79,700 KB
最終ジャッジ日時 2023-09-09 20:32:27
合計ジャッジ時間 13,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
78,216 KB
testcase_01 AC 577 ms
79,660 KB
testcase_02 AC 586 ms
78,744 KB
testcase_03 AC 597 ms
78,428 KB
testcase_04 AC 584 ms
79,004 KB
testcase_05 AC 511 ms
79,192 KB
testcase_06 AC 518 ms
79,408 KB
testcase_07 AC 511 ms
79,484 KB
testcase_08 AC 503 ms
78,656 KB
testcase_09 AC 582 ms
78,860 KB
testcase_10 AC 583 ms
79,004 KB
testcase_11 AC 577 ms
78,692 KB
testcase_12 AC 590 ms
78,436 KB
testcase_13 AC 533 ms
79,292 KB
testcase_14 AC 529 ms
79,180 KB
testcase_15 AC 529 ms
78,772 KB
testcase_16 AC 524 ms
79,104 KB
testcase_17 AC 545 ms
79,016 KB
testcase_18 AC 539 ms
79,700 KB
testcase_19 AC 553 ms
78,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
import bisect
stdin=sys.stdin
sys.setrecursionlimit(10 ** 8)

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
eps = 1e-9
sortkey = itemgetter(0)

###############################################################

lim=[0]*60
for i in range(2,60):
  lim[i] = int((10**18+10000)**(1/i))
def solve(x):
    cnt = [0 for _ in range(61)]
    for i in range(59, 1, -1):
        ok = 0
        ng = lim[i] + 1
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if mid ** i > x:
                ng = mid
            else:
                ok = mid
        ## 1を引いておく
        ok -= 1
        cnt[i] = ok - sum(cnt[::i])
    ## 1を足す
    return sum(cnt) + 1

T = ip()
for _ in range(T):
    now = ip()
    ng = 0; ok = 10 ** 18
    ## こっからはright, leftの二分探索
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid) < now:
            ng = mid
        else:
            ok = mid
    print(ok)
0