結果

問題 No.1666 累乗数
ユーザー ShirotsumeShirotsume
提出日時 2021-09-03 22:47:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 950 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 83,604 KB
最終ジャッジ日時 2024-05-09 05:54:02
合計ジャッジ時間 8,756 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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 math
def bi(b, x):
    #y ** b <= x となる最大のyを求める
    ok = 1
    ng = 10 ** 9
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if mid ** b <= x:
            ok = mid
        else:
            ng = mid
    return ok - 1

def check(x, k):
    #x以下の累乗数はk個以下であるか?
    cnt = [0] * 100
    for i in range(2, 100):
        cnt[i] += bi(i, x)
        for j in range(2 * i, 100, i):
            cnt[j] = cnt[j] - cnt[i]
    s = 1
    for i in range(100):
        if 2 ** i > x:
            break
        if cnt[i] > 0:
            s += cnt[i]
    if s <= k:
        return True
    else:
        return False
def solve():
    k = int(input())
    k -= 1
    ok = 10 ** 20
    ng = 0
    while abs(ng - ok) > 1:
        mid = (ok + ng) // 2
        if check(mid, k):
            ng = mid
        else:
            ok = mid
    print(ok)


t = int(input())

for _ in range(t):
    solve()
0