結果

問題 No.144 エラトステネスのざる
ユーザー 👑 rin204rin204
提出日時 2022-01-20 09:37:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 93,480 KB
最終ジャッジ日時 2023-08-15 08:33:20
合計ジャッジ時間 4,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,216 KB
testcase_01 AC 70 ms
71,156 KB
testcase_02 AC 72 ms
71,328 KB
testcase_03 AC 71 ms
71,184 KB
testcase_04 AC 72 ms
71,048 KB
testcase_05 AC 72 ms
71,320 KB
testcase_06 AC 76 ms
75,544 KB
testcase_07 AC 77 ms
75,980 KB
testcase_08 AC 77 ms
76,332 KB
testcase_09 AC 77 ms
75,800 KB
testcase_10 AC 78 ms
75,932 KB
testcase_11 AC 77 ms
76,108 KB
testcase_12 AC 77 ms
75,688 KB
testcase_13 AC 192 ms
92,672 KB
testcase_14 AC 218 ms
93,080 KB
testcase_15 AC 228 ms
93,472 KB
testcase_16 AC 227 ms
93,480 KB
testcase_17 AC 225 ms
93,112 KB
testcase_18 AC 233 ms
92,948 KB
testcase_19 AC 196 ms
93,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = input().split()
n = int(n)
p = float(p)

cnt = [0] * (n + 1)
for i in range(2, n + 1):
    for j in range(i * i, n + 1, i):
        cnt[j] += 1
        if j != i * i:
            cnt[j] += 1

ans = 0
for c in cnt[2:]:
    ans += pow(1 - p, c)
print(ans)
0