結果

問題 No.3296 81-like number
コンテスト
ユーザー N-noa21
提出日時 2025-11-12 13:43:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 2,461 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 64,812 KB
最終ジャッジ日時 2025-11-12 13:43:36
合計ジャッジ時間 2,537 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def eratosthenes(limit: int, minLimit: int = None):
    if minLimit and (minLimit < 0 or minLimit > limit):
        raise ValueError("incorrect minLimit")
    isPrime = [True] * max(limit + 1, 2)
    isPrime[0] = False
    isPrime[1] = False
    for p in range(2, limit + 1):
        if not isPrime[p]:
            continue
        for i in range(p * p, limit + 1, p):
            isPrime[i] = False
    if minLimit:
        return [i for i, x in enumerate(isPrime[minLimit:], start=minLimit) if x]
    else:
        return [i for i, x in enumerate(isPrime) if x]

N = int(input())
l = eratosthenes(int(N**0.5))
#print(l)
ans = 0
for i in l:
    tmp = i**2
    for j in range(40):
        if tmp <= N:
            ans += tmp
        else:
            break
        tmp *= i
print(ans)
0