結果

問題 No.1666 累乗数
ユーザー asumo0729asumo0729
提出日時 2021-09-14 21:35:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,081 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 156,792 KB
最終ジャッジ日時 2023-09-09 20:28:00
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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)

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

def solve(x):
    cnt = [0 for _ in range(61)]
    for i in range(59, 1, -1):
        ok = 0
        ng = 10 ** 9 + 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
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid) < now:
            ng = mid
        else:
            ok = mid
    print(ok)
0