結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2017-01-28 18:32:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 566 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 36,864 KB |
最終ジャッジ日時 | 2024-12-23 21:16:08 |
合計ジャッジ時間 | 15,359 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 15 TLE * 2 |
ソースコード
import math tmp = input().split(" ") N = int(tmp[0]) p = float(tmp[1]) cand = [i for i in range(3, N+1, 2)] primes = [2] while len(cand) > 0: 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 memo[i] = 1 else: cnt = 0 for j in range(2,i): if i % j == 0: cnt += 1 memo[i] = cnt count += (1.0-p) ** cnt print(count)