結果

問題 No.250 atetubouのzetubou
ユーザー code-devocode-devo
提出日時 2016-03-04 21:52:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 359 ms / 5,000 ms
コード長 975 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,508 KB
実行使用メモリ 22,300 KB
最終ジャッジ日時 2023-08-27 01:34:03
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 244 ms
22,152 KB
testcase_01 AC 115 ms
21,464 KB
testcase_02 AC 328 ms
22,184 KB
testcase_03 AC 359 ms
22,112 KB
testcase_04 AC 325 ms
22,072 KB
testcase_05 AC 331 ms
22,300 KB
testcase_06 AC 273 ms
22,164 KB
testcase_07 AC 178 ms
22,116 KB
testcase_08 AC 317 ms
21,908 KB
testcase_09 AC 258 ms
22,128 KB
testcase_10 AC 339 ms
21,920 KB
testcase_11 AC 234 ms
21,852 KB
testcase_12 AC 312 ms
22,000 KB
testcase_13 AC 211 ms
21,924 KB
testcase_14 AC 85 ms
20,924 KB
testcase_15 AC 155 ms
21,036 KB
testcase_16 AC 155 ms
21,012 KB
testcase_17 AC 156 ms
20,980 KB
testcase_18 AC 159 ms
21,160 KB
testcase_19 AC 155 ms
21,060 KB
testcase_20 AC 81 ms
20,160 KB
testcase_21 AC 82 ms
20,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

=begin
ループ変数の組み合わせの数は、combination(X + D - 1, D - 1)である。
組み合わせの場合の数がT以下かどうかを調べる。

解説)ループ変数の組み合わせの数の求め方。
まず、Xの数だけ"○"があると考える。(下図は、X=10の場合)

 ○○○○○○○○○○

ここに、D-1の数だけついたて"|"を入れる。(下図は、D=3の場合の一例)

 ○○○|○○○○○|○○

左からn番目の"○"のグループが、n番目のループのループ変数の値と考える。

よって、ループ変数の組み合わせの場合の数は、combination(X + D - 1, D - 1)。
=end

FACTORIAL = {}
FACTORIAL[0] = 1
for i in 1..3000 do
  FACTORIAL[i] = FACTORIAL[i-1] * i
end

gets
while line = gets do
  d, x, t = line.split.map(&:to_i)
  r = FACTORIAL[x + d - 1] / FACTORIAL[x] / FACTORIAL[d - 1] #combinationの計算
  puts r <= t ? "AC" : "ZETUBOU"
end
0