結果

問題 No.144 エラトステネスのざる
ユーザー shinshin
提出日時 2022-11-20 12:26:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 307 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 11,820 KB
実行使用メモリ 17,836 KB
最終ジャッジ日時 2023-10-21 11:50:09
合計ジャッジ時間 14,059 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
10,144 KB
testcase_02 WA -
testcase_03 AC 26 ms
10,144 KB
testcase_04 AC 25 ms
10,144 KB
testcase_05 AC 25 ms
10,144 KB
testcase_06 AC 26 ms
10,144 KB
testcase_07 AC 25 ms
10,228 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,813 ms
17,836 KB
testcase_14 AC 1,841 ms
17,732 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#エラトステネスのざる

n , p = input().split()

N = int(n)
P = float(p)

l = [0] * (N + 1)
ans = 0

for i in range(2 , N + 1):
    ans += (1 - P) ** l[i]
    for j in range(i + 1 , N // i + 1):
        if j == i:
            l[i * j] += 1
        else: 
            l[i * j] += 2
    
print(ans)

0