結果

問題 No.118 門松列(2)
コンテスト
ユーザー siman
提出日時 2015-01-07 02:32:51
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 206 ms / 5,000 ms
コード長 307 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 8,704 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2026-04-25 10:01:31
合計ジャッジ時間 6,470 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #
raw source code

class A
  def initialize
    n = gets.chomp.to_i
    a = gets.chomp.split(' ').map(&:to_i)

    count = 0

    cache = Hash.new(false)

    [*(1..100)].combination(3) do |list|
      count += list.map{|i| cache[i] || cache[i] = a.count(i)}.inject(:*)
    end

    puts count % (10 ** 9 + 7)
  end
end

A.new
0