結果

問題 No.144 エラトステネスのざる
ユーザー FromBooskaFromBooska
提出日時 2023-02-25 21:06:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 93,028 KB
最終ジャッジ日時 2023-10-11 17:12:09
合計ジャッジ時間 5,475 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 73 ms
71,348 KB
testcase_03 AC 75 ms
71,416 KB
testcase_04 AC 75 ms
71,520 KB
testcase_05 AC 76 ms
71,360 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 81 ms
76,272 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 303 ms
93,028 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 確率が独立でなく従属なケース
# たとえば8
# 2のときに倍数を除くのを忘れていれば、4も8も生きている
# 4が生きている場合、死んでいる場合の場合分けは必要ない

N, p = map(float, input().split())
N = int(N)

is_prime = [1]*(N+1)
is_prime[0] = 0  
is_prime[1] = 0
div_count = [0]*(N+1)

for p in range(2, N+1):
    for q in range(2*p, N+1, p):
        is_prime[q] = 0
        div_count[q] += 1

EV = 0
for i in range(2, N+1):
    EV += 1/(2**div_count[i])
print(EV)
0