結果

問題 No.73 helloworld
ユーザー code-devocode-devo
提出日時 2016-01-20 04:10:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 11,580 KB
実行使用メモリ 15,352 KB
最終ジャッジ日時 2023-09-11 23:06:03
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,172 KB
testcase_01 AC 81 ms
15,280 KB
testcase_02 AC 80 ms
15,352 KB
testcase_03 AC 80 ms
15,068 KB
testcase_04 AC 85 ms
15,352 KB
testcase_05 AC 79 ms
15,108 KB
testcase_06 AC 80 ms
15,304 KB
testcase_07 AC 80 ms
15,344 KB
testcase_08 AC 81 ms
15,324 KB
testcase_09 AC 82 ms
15,348 KB
testcase_10 AC 80 ms
15,120 KB
testcase_11 AC 84 ms
15,160 KB
testcase_12 AC 82 ms
15,152 KB
testcase_13 AC 80 ms
15,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def nCr(n, r)
  r = n - r if n - r < r
  return 1 if r == 0
  a = ((n-r+1)..n).inject(&:*)
  b = (1..r).inject(&:*)
  return Rational(a, b).to_i
end

def calc_l(cnt)
  return 0 if cnt < 3
  return (2..(cnt-1)).map{|n| nCr(n, 2) * nCr(cnt - n, 1)}.max
end

def calc_o(cnt)
  return 0 if cnt < 2
  q = cnt / 2
  return q * (cnt - q)
end

S = "abcdefghijklmnopqrstuvwxyz"
CS = Hash[$stdin.read.split.map(&:to_i).map.with_index{|n,i| [S[i], n.to_i]}]

h, e, l, o, w, r, d = CS["h"], CS["e"], CS["l"], CS["o"], CS["w"], CS["r"], CS["d"]
puts h * e * calc_l(l) * calc_o(o) * w * r * d
0