結果

問題 No.1666 累乗数
ユーザー るさるさ
提出日時 2021-09-03 22:16:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 872 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 79,588 KB
最終ジャッジ日時 2023-08-21 22:19:50
合計ジャッジ時間 22,002 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
77,616 KB
testcase_01 AC 712 ms
78,032 KB
testcase_02 AC 710 ms
78,324 KB
testcase_03 AC 708 ms
79,588 KB
testcase_04 AC 704 ms
79,296 KB
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 #

def prime_table(n):
    n += 1
    table = [i if i%2 else 2 for i in range(n)]
    for i in range(3, n, 2):
        if table[i] == i:
            for j in range(i*i, n, 2*i):
                if table[j] == j:
                    table[j] = i
    return table

def pc(n, table):
    p = set()
    while n != 1:
        pp = table[n]
        if pp in p: return 0
        p.add(pp)
        n //= pp
    return len(p)%2*2 - 1

pt = prime_table(100)

def cnt(n):
    ret = 0
    for i in range(2, 60):
        tp = int(n ** (1/i))
        while (tp+1) ** i <= n:
            tp += 1
        #print(i, tp-1)
        ret += (tp-1) * pc(i, pt)
    return ret+1


for i in range(int(input())):
    l, r = -1, 10**18
    k = int(input())
    while r-l != 1:
        t = (l+r) // 2
        c = cnt(t)
        if c >= k:
            r = t
        else:
            l = t
    print(r)
0