結果
| 問題 |
No.3296 81-like number
|
| コンテスト | |
| ユーザー |
くろ
|
| 提出日時 | 2025-10-05 15:37:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 330 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2025-10-05 15:37:10 |
| 合計ジャッジ時間 | 1,597 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
n = int(input())
n_s = int(n**(1/2))
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]
primes = eratosthenes(n_s)
s = 0
i = 63
for p in primes:
while p**i > n:
i -= 1
s += (p**(i+1)-1)/(p-1)-(1+p)
print(int(s))
くろ