結果
問題 | No.144 エラトステネスのざる |
ユーザー | nbisco |
提出日時 | 2017-01-28 18:34:01 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 525 bytes |
コンパイル時間 | 545 ms |
コンパイル使用メモリ | 87,020 KB |
実行使用メモリ | 263,612 KB |
最終ジャッジ日時 | 2023-08-25 13:22:12 |
合計ジャッジ時間 | 5,324 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
75,728 KB |
testcase_01 | AC | 70 ms
71,296 KB |
testcase_02 | AC | 69 ms
71,360 KB |
testcase_03 | AC | 70 ms
71,332 KB |
testcase_04 | AC | 71 ms
71,472 KB |
testcase_05 | AC | 72 ms
71,300 KB |
testcase_06 | AC | 90 ms
76,660 KB |
testcase_07 | AC | 88 ms
76,976 KB |
testcase_08 | AC | 86 ms
77,368 KB |
testcase_09 | AC | 89 ms
77,296 KB |
testcase_10 | AC | 87 ms
77,268 KB |
testcase_11 | AC | 88 ms
77,196 KB |
testcase_12 | AC | 87 ms
77,204 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
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 else: cnt = 0 for j in range(2,i): if i % j == 0: cnt += 1 count += (1.0-p) ** cnt print(count)