結果

問題 No.73 helloworld
コンテスト
ユーザー siman
提出日時 2016-03-26 03:21:11
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 855 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 359 ms
コンパイル使用メモリ 8,832 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2026-03-19 01:09:17
合計ジャッジ時間 1,889 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

class Integer
  def combination(k)
    self.factorial/(k.factorial*(self-k).factorial)
  end

  def permutation(k)
    self.factorial/(self-k).factorial
  end

  def factorial
    return 1 if self == 0
    (1..self).inject(:*)
  end
end

class Yukicoder
  def initialize
    hash = Hash.new(0)

    26.times do |i|
      hash[(97+i).chr] = gets.to_i
    end

    answer = 1

    %w(d e h l o r w).each do |ch|
      if ch == 'l'
        max_val = 0

        1.upto(hash[ch]-2) do |n|
          max_val = [max_val, (hash[ch]-n).combination(2) * n].max
        end

        answer *= max_val
      elsif ch == 'o'
        max_val = 0

        1.upto(hash[ch]-1) do |n|
          max_val = [max_val, (hash[ch]-n) * n].max
        end

        answer *= max_val
      else
        answer *= hash[ch]
      end
    end

    puts answer
  end
end

Yukicoder.new
0