結果
| 問題 |
No.73 helloworld
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2016-03-26 03:21:11 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 5,000 ms |
| コード長 | 855 bytes |
| コンパイル時間 | 70 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-06-29 13:13:45 |
| 合計ジャッジ時間 | 1,759 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
Syntax OK
ソースコード
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
siman