結果

問題 No.144 エラトステネスのざる
ユーザー FromBooskaFromBooska
提出日時 2023-02-15 13:29:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 85,372 KB
最終ジャッジ日時 2023-09-24 22:50:03
合計ジャッジ時間 5,883 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,272 KB
testcase_01 AC 66 ms
71,208 KB
testcase_02 AC 65 ms
71,696 KB
testcase_03 AC 66 ms
71,160 KB
testcase_04 AC 69 ms
71,272 KB
testcase_05 AC 71 ms
71,272 KB
testcase_06 AC 75 ms
76,304 KB
testcase_07 AC 78 ms
76,216 KB
testcase_08 AC 73 ms
76,352 KB
testcase_09 AC 73 ms
76,772 KB
testcase_10 AC 81 ms
76,640 KB
testcase_11 AC 72 ms
76,232 KB
testcase_12 AC 70 ms
75,976 KB
testcase_13 AC 168 ms
85,008 KB
testcase_14 AC 218 ms
85,372 KB
testcase_15 AC 221 ms
85,340 KB
testcase_16 AC 216 ms
85,300 KB
testcase_17 AC 217 ms
85,328 KB
testcase_18 AC 218 ms
85,340 KB
testcase_19 AC 213 ms
85,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

div_count = [0]*(N+1)

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

ans = 0
for i in range(2, N+1):
    if div_count[i] == 0:
        ans += 1
    else:
        ans += pow(1-exe_prob, div_count[i])

print(ans)
0