結果

問題 No.144 エラトステネスのざる
ユーザー iwotiwot
提出日時 2020-06-24 14:51:37
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 208 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 49,032 KB
最終ジャッジ日時 2023-09-16 21:06:48
合計ジャッジ時間 15,890 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
15,276 KB
testcase_01 AC 71 ms
15,140 KB
testcase_02 AC 71 ms
15,008 KB
testcase_03 AC 71 ms
15,072 KB
testcase_04 AC 70 ms
15,008 KB
testcase_05 AC 72 ms
15,292 KB
testcase_06 AC 75 ms
15,152 KB
testcase_07 AC 75 ms
15,072 KB
testcase_08 AC 74 ms
15,088 KB
testcase_09 AC 74 ms
15,232 KB
testcase_10 AC 72 ms
15,108 KB
testcase_11 AC 73 ms
15,008 KB
testcase_12 AC 75 ms
15,068 KB
testcase_13 AC 1,648 ms
23,416 KB
testcase_14 AC 1,668 ms
23,256 KB
testcase_15 AC 1,688 ms
23,340 KB
testcase_16 AC 1,691 ms
23,232 KB
testcase_17 AC 1,841 ms
23,368 KB
testcase_18 TLE -
testcase_19 AC 1,676 ms
23,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, p = gets.strip.split
n = n.to_i
p = p.to_f

p2 = 1.0 - p
s = (1..n+1).map {|i| 1.0}
ans = 0.0

(2..n).each do |i|
    ans += s[i]
    (i*2..n).step(i) do |j|
        s[j] = s[j] * p2
    end
end

puts ans
0