結果

問題 No.144 エラトステネスのざる
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-22 22:33:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 261 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 85,456 KB
最終ジャッジ日時 2023-09-16 19:31:53
合計ジャッジ時間 3,879 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,508 KB
testcase_01 AC 69 ms
71,188 KB
testcase_02 AC 75 ms
71,532 KB
testcase_03 AC 72 ms
71,276 KB
testcase_04 AC 72 ms
71,084 KB
testcase_05 AC 70 ms
71,476 KB
testcase_06 AC 78 ms
75,996 KB
testcase_07 AC 73 ms
76,700 KB
testcase_08 AC 73 ms
76,740 KB
testcase_09 AC 75 ms
76,720 KB
testcase_10 AC 73 ms
76,684 KB
testcase_11 AC 75 ms
76,728 KB
testcase_12 AC 74 ms
76,176 KB
testcase_13 AC 186 ms
84,940 KB
testcase_14 AC 232 ms
85,456 KB
testcase_15 AC 235 ms
85,284 KB
testcase_16 AC 242 ms
85,288 KB
testcase_17 AC 231 ms
85,280 KB
testcase_18 AC 231 ms
85,448 KB
testcase_19 AC 207 ms
85,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

cnt = [0] * (n + 1)

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

res = cnt.count(1)
for c in cnt:
    if c > 1:
        res += (1 - p) ** (c - 1)
print(res)
0