結果

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

ソースコード

diff #

def eratosthenes(n):
    is_prime = [False, False] + [True] * (n-1)
    for p in range(2, n+1):
        if not(is_prime[p]):
            continue
        for k in range(p*2, n+1, p):
            is_prime[k] = False
    return is_prime

import math
N=int(input())
pr = eratosthenes(math.isqrt(N)+1)
ans=0
for i in range(1,len(pr)):
    if pr[i]:
        tmp = i
        while tmp <= N:
            tmp*=i
            if tmp <= N:
                ans+=tmp
print(ans)
0