結果

問題 No.1666 累乗数
ユーザー dachengzdachengz
提出日時 2022-12-17 15:18:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-28 09:40:35
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
64,640 KB
testcase_01 AC 135 ms
77,056 KB
testcase_02 AC 133 ms
76,928 KB
testcase_03 AC 135 ms
76,800 KB
testcase_04 AC 143 ms
76,928 KB
testcase_05 AC 186 ms
76,928 KB
testcase_06 AC 181 ms
76,800 KB
testcase_07 AC 180 ms
76,672 KB
testcase_08 AC 180 ms
76,672 KB
testcase_09 AC 153 ms
76,928 KB
testcase_10 AC 155 ms
76,672 KB
testcase_11 AC 157 ms
76,928 KB
testcase_12 AC 158 ms
77,056 KB
testcase_13 AC 177 ms
76,672 KB
testcase_14 AC 179 ms
77,056 KB
testcase_15 AC 185 ms
77,056 KB
testcase_16 AC 189 ms
76,928 KB
testcase_17 AC 171 ms
76,672 KB
testcase_18 AC 174 ms
76,800 KB
testcase_19 AC 173 ms
77,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def introot(n, r):
    if n <= 0:
        return 0
    r1 = r - 1
    x = int(n ** (1.0 / r) * (1 + 1e-12))
    while True:
        y = (r1 * x + n // (x ** r1)) // r
        if y >= x:
            return x
        x = y

mu = list(range(65))
for p in range(2, 65):
    if mu[p] != p:
        continue
    q = p * p
    for d in range(q, 65, q):
        mu[d] = 0
    for d in range(p, 65, p):
        mu[d] = (mu[d] <= 0) - (mu[d] >= 0)

def count(n):
    cnt = 1
    e = 2
    while n >> e:
        if mu[e]:
            cnt -= mu[e] * (introot(n, e) - 1)
        e += 1
    return cnt

T = int(input())
for _ in range(T):
    C = int(input())
    if C == 1:
        print(1)
        continue
    lo = 1
    hi = 10 ** 18
    while hi - lo > 1:
        md = (hi + lo) // 2
        if count(md) >= C:
            hi = md
        else:
            lo = md
    print(hi)
0