結果

問題 No.1022 Power Equation
ユーザー tamatotamato
提出日時 2020-04-10 23:13:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 81,696 KB
最終ジャッジ日時 2023-10-14 04:44:50
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,596 KB
testcase_01 AC 75 ms
75,972 KB
testcase_02 AC 84 ms
76,700 KB
testcase_03 AC 93 ms
76,968 KB
testcase_04 AC 205 ms
80,308 KB
testcase_05 AC 253 ms
81,328 KB
testcase_06 AC 249 ms
81,484 KB
testcase_07 AC 250 ms
81,696 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):
                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