結果

問題 No.1666 累乗数
ユーザー tamatotamato
提出日時 2021-09-03 23:09:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,279 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 87,520 KB
実行使用メモリ 282,496 KB
最終ジャッジ日時 2023-08-22 00:47:21
合計ジャッジ時間 25,272 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,092 ms
280,772 KB
testcase_01 AC 1,135 ms
281,116 KB
testcase_02 AC 1,130 ms
281,044 KB
testcase_03 AC 1,123 ms
281,744 KB
testcase_04 AC 1,154 ms
280,576 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 #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    from math import sqrt, floor
    input = sys.stdin.readline

    def square_root(n):
        r = floor(sqrt(n))
        for x in range(3, -4, -1):
            if (r+x) ** 2 <= n:
                return r

    M = 15 * 10 ** 5
    MAX = 2 * 10 ** 18
    S = {1}
    for a in range(2, M+1):
        cur = a
        for b in range(2, 70):
            cur *= a
            if cur > MAX:
                break
            S.add(cur)
    S = sorted(list(S))
    kk = bisect_left(S, M+1)

    for _ in range(int(input())):
        K = int(input())
        ok = MAX
        ng = 0
        mid = (ok + ng) // 2
        while ok - ng > 1:
            r = square_root(mid)
            if r <= M:
                j = bisect_left(S, mid+1)
                if j >= K:
                    ok = mid
                else:
                    ng = mid
            else:
                k = bisect_left(S, r+1)
                j = bisect_left(S, mid + 1) + (r - M) - (k - kk)
                if j >= k:
                    ok = mid
                else:
                    ng = mid

            mid = (ok + ng) // 2
        print(ok)
        assert ok != MAX


if __name__ == '__main__':
    main()
0