結果

問題 No.1022 Power Equation
ユーザー chocoruskchocorusk
提出日時 2020-04-07 17:46:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 8,076 KB
最終ジャッジ日時 2023-09-22 02:28:10
合計ジャッジ時間 3,193 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
8,072 KB
testcase_01 AC 273 ms
7,984 KB
testcase_02 AC 274 ms
8,076 KB
testcase_03 AC 271 ms
7,868 KB
testcase_04 AC 282 ms
7,996 KB
testcase_05 AC 289 ms
8,032 KB
testcase_06 AC 281 ms
8,072 KB
testcase_07 AC 290 ms
7,940 KB
testcase_08 AC 283 ms
7,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
t=int(input())
for _ in range(t):
    n=int(input())
    ans=n*(2*n-1)
    for i in range(1, 31):
        for j in range(1, 31):
            k=max(i, j)
            if k==1 or math.gcd(i, j)>1:
                continue
            l=1
            r=32000
            while r-l>1:
                m=(l+r)//2
                if m**k<=n:
                    l=m
                else:
                    r=m
            ans+=n//k*(l-1)
    print(ans)
0