結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2023-09-01 16:39:37 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 1,150 ms / 2,000 ms |
コード長 | 465 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 8,192 KB |
実行使用メモリ | 20,992 KB |
最終ジャッジ日時 | 2025-01-03 06:40:48 |
合計ジャッジ時間 | 10,210 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/local/bin/rubyclass EratosthenesLikeSievedef initialize(*arg)@n,@k = argenddef ansr = 0sigma = Array.new(@n+1,0)pb = 1-@ki=2while i <= @nlast = @n/ij=2while j<=lastsigma[j*i]+=1j+=1endr += pb**sigma[i]i+=1endrendend### END: class EratosthenesLikeSieveiod = STDINn,k = iod.gets.splitputs EratosthenesLikeSieve.new(n.to_i,k.to_f).ansexit 0