結果

問題 No.144 エラトステネスのざる
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-26 12:35:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 85,160 KB
最終ジャッジ日時 2023-09-07 13:46:50
合計ジャッジ時間 4,286 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,384 KB
testcase_01 AC 75 ms
71,480 KB
testcase_02 AC 75 ms
71,336 KB
testcase_03 AC 75 ms
71,224 KB
testcase_04 AC 73 ms
71,080 KB
testcase_05 AC 74 ms
71,464 KB
testcase_06 AC 80 ms
76,016 KB
testcase_07 AC 79 ms
76,456 KB
testcase_08 AC 78 ms
76,488 KB
testcase_09 AC 80 ms
76,404 KB
testcase_10 AC 80 ms
76,596 KB
testcase_11 AC 79 ms
76,420 KB
testcase_12 AC 79 ms
76,268 KB
testcase_13 AC 188 ms
84,828 KB
testcase_14 AC 243 ms
85,120 KB
testcase_15 AC 252 ms
85,124 KB
testcase_16 AC 246 ms
85,156 KB
testcase_17 AC 250 ms
85,160 KB
testcase_18 AC 252 ms
85,148 KB
testcase_19 AC 216 ms
84,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,p=input().split()
n=int(n)
p=1-float(p)
mat=[0]*(n+1)
# mat[i]:iが素数リストに残るために飛ばさないといけない処理の回数
ans=0
for i in range(2,n+1):
  ii=i+i
  while ii<=n:
    mat[ii]+=1
    ii+=i
  ans+=pow(p,mat[i])
print(ans)
#print([pow(p,x) for x in mat])
0