結果

問題 No.390 最長の数列
ユーザー miraxialmiraxial
提出日時 2016-07-08 22:54:14
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2024-04-21 07:34:59
合計ジャッジ時間 7,119 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
12,032 KB
testcase_01 AC 77 ms
12,288 KB
testcase_02 AC 79 ms
12,288 KB
testcase_03 AC 78 ms
12,160 KB
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
h=Hash.new([])
i=0
a=gets.split.map(&:to_i).sort
b=[]
0.upto(n-2) do |i|
  if !b.include?(a[i])
    (i+1).upto(n-1) do |ii|
      if a[ii]%a[i]==0
        h[a[i]]+=[a[ii]]
        b+=[a[ii]]
      end
    end
  end
end
while true do
  i+=1
  break if h=={}
  b=[]
  hh=Hash.new([])
  h.each do |e,v|
    vl=v.length
    if vl==1
      break
    end
    0.upto(vl-2) do |i|
      if !b.include?(v[i])
        (i+1).upto(vl-1) do |ii|
          if v[ii]%v[i]==0
            hh[v[i]]+=[v[ii]]
            b+=[v[ii]]
          end
        end
      end
    end
  end
  h=hh.dup
end
p i
0