結果
問題 | No.6 使いものにならないハッシュ |
ユーザー |
![]() |
提出日時 | 2019-05-29 15:06:56 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 212 ms / 5,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 129 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 13,696 KB |
最終ジャッジ日時 | 2024-09-16 16:49:50 |
合計ジャッジ時間 | 6,271 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
コンパイルメッセージ
Syntax OK
ソースコード
require "prime" def to_hash(x) x = x.digits.sum until x < 10 x end k = gets.to_i n = gets.to_i primes = Prime.each(n).filter{|prime| k <= prime}.to_a answers = Hash.new(-1) primes.size.times do |x| hashes = [] (x...primes.size).each do |y| hash = to_hash(primes[y]) break if hashes.include?(hash) hashes << hash end answers[hashes.size] = [answers[hashes.size], x].max end puts primes[answers[answers.keys.max]]