結果

問題 No.144 エラトステネスのざる
ユーザー tamura2004tamura2004
提出日時 2021-03-09 20:48:04
言語 Crystal
(1.11.2)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 192 bytes
コンパイル時間 11,936 ms
コンパイル使用メモリ 301,588 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-19 20:21:27
合計ジャッジ時間 13,400 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 46 ms
10,624 KB
testcase_14 AC 46 ms
10,612 KB
testcase_15 AC 45 ms
10,568 KB
testcase_16 AC 47 ms
10,624 KB
testcase_17 AC 46 ms
10,624 KB
testcase_18 AC 50 ms
10,564 KB
testcase_19 AC 46 ms
10,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,p = gets.to_s.split
n = n.to_i
p = p.to_f64

dp = Array.new(n+1){ 1.0_f64 }
ans = 0.0_f64
2.upto(n) do |i|
  ans += dp[i]
  i.step(to: n, by: i) do |j|
    dp[j] *= (1 - p)
  end
end

pp ans
0