結果

問題 No.144 エラトステネスのざる
ユーザー FromBooskaFromBooska
提出日時 2023-10-15 14:34:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 92,728 KB
最終ジャッジ日時 2023-10-15 14:34:58
合計ジャッジ時間 4,351 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,296 KB
testcase_01 AC 72 ms
71,296 KB
testcase_02 AC 73 ms
71,472 KB
testcase_03 AC 71 ms
71,188 KB
testcase_04 AC 73 ms
71,348 KB
testcase_05 AC 76 ms
71,424 KB
testcase_06 AC 153 ms
76,460 KB
testcase_07 AC 78 ms
76,340 KB
testcase_08 AC 78 ms
76,792 KB
testcase_09 AC 78 ms
76,668 KB
testcase_10 AC 77 ms
76,796 KB
testcase_11 AC 77 ms
76,800 KB
testcase_12 AC 78 ms
76,308 KB
testcase_13 AC 215 ms
92,420 KB
testcase_14 AC 241 ms
92,340 KB
testcase_15 AC 250 ms
92,728 KB
testcase_16 AC 225 ms
92,396 KB
testcase_17 AC 234 ms
92,572 KB
testcase_18 AC 230 ms
92,288 KB
testcase_19 AC 236 ms
92,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 愚直実装

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

survive = [1]*(N+1)
survive[0]=0
survive[1]=0
for p in range(2, N+1):
    for j in range(p*2, N+1, p):
        #survive[j] *= (1-prob)*survive[p] これだとワークしない
        survive[j] *= (1-prob)
    #print('p', p, survive)
    
ans = sum(survive)
print(ans)




0