結果
問題 | No.144 エラトステネスのざる |
ユーザー | hytkxd |
提出日時 | 2023-08-31 22:42:47 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 526 bytes |
コンパイル時間 | 743 ms |
コンパイル使用メモリ | 11,160 KB |
実行使用メモリ | 23,524 KB |
最終ジャッジ日時 | 2023-08-31 22:43:07 |
合計ジャッジ時間 | 18,968 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
15,344 KB |
testcase_01 | AC | 80 ms
15,184 KB |
testcase_02 | AC | 78 ms
15,232 KB |
testcase_03 | AC | 80 ms
15,096 KB |
testcase_04 | AC | 80 ms
15,340 KB |
testcase_05 | AC | 81 ms
15,420 KB |
testcase_06 | AC | 85 ms
15,376 KB |
testcase_07 | AC | 82 ms
15,608 KB |
testcase_08 | AC | 82 ms
15,436 KB |
testcase_09 | AC | 84 ms
15,428 KB |
testcase_10 | AC | 83 ms
15,392 KB |
testcase_11 | AC | 82 ms
15,640 KB |
testcase_12 | AC | 82 ms
15,440 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/local/bin/ruby class EratosthenesLikeSieve def initialize(*arg) @n,@k = arg @sigma = Array.new(@n+1,0) eratosthenes end private def eratosthenes (2..@n).each do |i| i.step(@n,i) do |j| @sigma[j]+=1 end end end public def ans r = 0 pb = 1-@k (2..@n).each do |i| r += 1*pb**(@sigma[i]-1) end r end end ### END: class EratosthenesLikeSieve iod = STDIN n,k = iod.gets.split puts EratosthenesLikeSieve.new(n.to_i,k.to_f).ans exit 0