結果

問題 No.1022 Power Equation
ユーザー 👑 tamatotamato
提出日時 2020-04-10 23:16:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 82,296 KB
最終ジャッジ日時 2023-10-14 04:58:38
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,508 KB
testcase_01 AC 76 ms
75,712 KB
testcase_02 AC 88 ms
76,384 KB
testcase_03 AC 90 ms
76,376 KB
testcase_04 AC 231 ms
80,680 KB
testcase_05 AC 304 ms
82,208 KB
testcase_06 AC 285 ms
82,128 KB
testcase_07 AC 285 ms
82,296 KB
testcase_08 AC 187 ms
78,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    from math import log, gcd, floor
    input = sys.stdin.buffer.readline

    div = [set() for _ in range(41)]
    for i in range(1, 41):
        for j in range(2, 41):
            if i%j==0:
                div[i].add(j)

    for _ in range(int(input())):
        N = int(input())
        ans = 0
        sqrtN = int(N**0.5)
        seen = [0] * (sqrtN + 1)
        for a in range(2, sqrtN+1):
            if seen[a]:
                continue
            L = 0
            while a ** L <= N:
                L += 1
            L -= 1
            for i in range(1, L+1):
                if a**i <= sqrtN:
                    seen[a**i] = 1
                for j in range(i+1, L+1):
                    g = gcd(i, j)
                    ans += N // (j // g)
        ans *= 2
        ans += N**2 # b==d
        ans += N**2-N # a==c==1
        print(ans)


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