結果

問題 No.1022 Power Equation
ユーザー tamatotamato
提出日時 2020-04-10 23:15:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 82,984 KB
最終ジャッジ日時 2023-10-14 04:49:57
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,800 KB
testcase_01 AC 80 ms
75,456 KB
testcase_02 AC 92 ms
76,712 KB
testcase_03 AC 99 ms
76,936 KB
testcase_04 AC 241 ms
80,988 KB
testcase_05 AC 315 ms
82,508 KB
testcase_06 AC 302 ms
82,984 KB
testcase_07 AC 300 ms
82,392 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = floor(log(N, a))
            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