結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
nbisco
|
| 提出日時 | 2017-01-28 17:43:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 504 bytes |
| 記録 | |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 47,872 KB |
| 最終ジャッジ日時 | 2024-12-23 21:13:46 |
| 合計ジャッジ時間 | 23,039 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 RE * 3 TLE * 7 |
ソースコード
tmp = input().split(" ")
N = int(tmp[0])
p = float(tmp[1])
cand = [i for i in range(3, N+1, 2)]
primes = [2]
while True:
primes.append(cand[0])
if primes[-1] * primes[-1] > N:
break
cand = [i for i in cand[1:] if i % primes[-1] != 0]
primes = set(primes)
count = 0
for i in range(2, N+1):
if i in primes:
count += 1.0
else:
cnt = 0
for j in range(2, i):
if i % j == 0:
cnt += 1
count += (1.0-p) ** cnt
print(count)
nbisco