結果

問題 No.144 エラトステネスのざる
ユーザー しらっ亭しらっ亭
提出日時 2015-09-10 00:50:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 92,412 KB
最終ジャッジ日時 2023-09-26 10:22:25
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,300 KB
testcase_01 AC 72 ms
71,236 KB
testcase_02 AC 76 ms
71,392 KB
testcase_03 AC 73 ms
71,236 KB
testcase_04 AC 73 ms
71,072 KB
testcase_05 AC 74 ms
71,128 KB
testcase_06 AC 78 ms
75,856 KB
testcase_07 AC 78 ms
76,128 KB
testcase_08 AC 78 ms
76,056 KB
testcase_09 AC 76 ms
76,136 KB
testcase_10 AC 76 ms
76,056 KB
testcase_11 AC 77 ms
76,008 KB
testcase_12 AC 77 ms
76,072 KB
testcase_13 AC 163 ms
92,256 KB
testcase_14 AC 160 ms
92,224 KB
testcase_15 AC 165 ms
92,356 KB
testcase_16 AC 160 ms
92,368 KB
testcase_17 AC 159 ms
92,412 KB
testcase_18 AC 170 ms
92,188 KB
testcase_19 AC 158 ms
92,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    inp = input().split()
    N = int(inp[0])
    p = 1 - float(inp[1])

    s = [1.0] * (N + 1)
    for x in range(2, N + 1):
        for i in range(x + x, N + 1, x):
            s[i] *= p

    s[0] = 0
    s[1] = 0

    print(sum(s))

if __name__ == '__main__':
    solve()
0