結果

問題 No.144 エラトステネスのざる
ユーザー Yuki IwatakeYuki Iwatake
提出日時 2020-11-29 15:18:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 236 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 7,952 KB
最終ジャッジ日時 2023-10-11 02:27:19
合計ジャッジ時間 3,936 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,952 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 17 ms
7,780 KB
testcase_03 AC 16 ms
7,812 KB
testcase_04 AC 16 ms
7,912 KB
testcase_05 AC 15 ms
7,852 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,p = input().split()
N = int(N)
p = float(p)
A0 = list(range(2,N+1))

def E(A):
    if len(A)==0:
        return 0
    a = A[0]
    A_s = [i for i in A if i%a != 0]
    A_f = A[1:]
    return p*(E(A_s)+1)+(1-p)*(E(A_f)+1)

print(E(A0))
0