結果

問題 No.3296 81-like number
ユーザー hotate29
提出日時 2025-10-05 13:42:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 62,720 KB
最終ジャッジ日時 2025-10-05 13:43:08
合計ジャッジ時間 1,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt

n = int(input())

# ~sqrt(N)の素数

MAX = isqrt(n)
sieve = list(range(MAX + 1))
sieve[1] = 0

for i in range(isqrt(MAX) + 1):
    if sieve[i] != 0:
        for j in range(i + i, MAX + 1, i):
            sieve[j] = 0

primes = [pi for pi in sieve if pi != 0]
ans = 0
for p in primes:
    x = p * p
    while x <= n:
        ans += x
        x *= p
print(ans)
0