結果

問題 No.6 使いものにならないハッシュ
ユーザー gigurururu
提出日時 2014-11-04 16:19:29
言語 Ruby
(3.4.1)
結果
AC  
実行時間 231 ms / 5,000 ms
コード長 317 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-09-16 16:21:40
合計ジャッジ時間 6,862 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require"prime"
k=gets.to_i
n=gets.to_i
l=Prime.each(n).select{|i|i>=k}.map{|i|j=i;j=j.to_s.chars.inject(0){|s,c|s+c.to_i} while j>9;[i,j]}
a=[]
cnt=[0]*10
max=0
ans=0
l.each{|i,j|
  a<<[i,j]
  cnt[j]+=1
  cnt[a.shift[1]]-=1 while cnt[j]>1
  if max<=a.size
    max=a.size
    ans=a[0][0]
  end
}
p ans
0