結果

問題 No.106 素数が嫌い!2
ユーザー siman
提出日時 2015-01-14 04:11:03
言語 Ruby
(3.4.1)
結果
AC  
実行時間 1,543 ms / 5,000 ms
コード長 365 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 7,168 KB
実行使用メモリ 37,276 KB
最終ジャッジ日時 2024-12-26 02:49:57
合計ジャッジ時間 13,154 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: assigned but unused variable - count
Syntax OK

ソースコード

diff #

require 'prime'

class Yukicoder
  def initialize
    n, k = gets.chomp.split(' ').map(&:to_i)

    count = 0
    list = Array.new(n+1, 0)

    Prime.each(n, Prime::EratosthenesGenerator.new) do |number|
      x = 1

      while n >= number * x
        list[number * x] += 1
        x += 1
      end
    end

    puts list.count{|i| i >= k}
  end
end

Yukicoder.new
0