結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2023-08-31 22:51:02 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 537 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 8,064 KB |
実行使用メモリ | 21,120 KB |
最終ジャッジ日時 | 2025-01-03 04:57:00 |
合計ジャッジ時間 | 17,842 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 7 |
コンパイルメッセージ
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| last = @n/i (2..last).each do |j| @sigma[j*i]+=1 end end end public def ans r = 0 pb = 1-@k (2..@n).each do |i| r += 1*pb**@sigma[i] 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