結果

問題 No.144 エラトステネスのざる
ユーザー 👑 rin204rin204
提出日時 2022-01-20 09:37:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 91,904 KB
最終ジャッジ日時 2024-05-02 20:16:03
合計ジャッジ時間 3,211 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,096 KB
testcase_01 AC 40 ms
51,584 KB
testcase_02 AC 40 ms
51,712 KB
testcase_03 AC 40 ms
51,712 KB
testcase_04 AC 41 ms
51,584 KB
testcase_05 AC 41 ms
51,712 KB
testcase_06 AC 48 ms
58,112 KB
testcase_07 AC 47 ms
58,880 KB
testcase_08 AC 47 ms
58,752 KB
testcase_09 AC 47 ms
58,880 KB
testcase_10 AC 47 ms
58,752 KB
testcase_11 AC 48 ms
58,624 KB
testcase_12 AC 47 ms
58,624 KB
testcase_13 AC 169 ms
91,648 KB
testcase_14 AC 189 ms
91,776 KB
testcase_15 AC 193 ms
91,904 KB
testcase_16 AC 186 ms
91,520 KB
testcase_17 AC 189 ms
91,776 KB
testcase_18 AC 191 ms
91,904 KB
testcase_19 AC 178 ms
91,776 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