結果

問題 No.129 お年玉(2)
ユーザー simansiman
提出日時 2016-03-23 00:59:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 182 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 11,508 KB
実行使用メモリ 64,936 KB
最終ジャッジ日時 2023-08-18 17:36:12
合計ジャッジ時間 8,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
19,184 KB
testcase_01 AC 182 ms
64,692 KB
testcase_02 AC 78 ms
15,156 KB
testcase_03 AC 78 ms
15,088 KB
testcase_04 AC 77 ms
15,048 KB
testcase_05 AC 120 ms
38,044 KB
testcase_06 AC 135 ms
48,236 KB
testcase_07 AC 146 ms
52,516 KB
testcase_08 AC 130 ms
41,480 KB
testcase_09 AC 141 ms
48,224 KB
testcase_10 AC 150 ms
54,740 KB
testcase_11 AC 123 ms
39,320 KB
testcase_12 AC 158 ms
50,316 KB
testcase_13 AC 161 ms
51,496 KB
testcase_14 AC 139 ms
48,072 KB
testcase_15 AC 127 ms
42,264 KB
testcase_16 AC 135 ms
47,964 KB
testcase_17 AC 147 ms
51,180 KB
testcase_18 AC 149 ms
48,120 KB
testcase_19 AC 153 ms
51,700 KB
testcase_20 AC 144 ms
51,128 KB
testcase_21 AC 166 ms
64,936 KB
testcase_22 AC 123 ms
41,172 KB
testcase_23 AC 150 ms
56,568 KB
testcase_24 AC 156 ms
53,936 KB
testcase_25 AC 122 ms
39,316 KB
testcase_26 AC 126 ms
40,160 KB
testcase_27 AC 127 ms
39,168 KB
testcase_28 AC 171 ms
64,672 KB
testcase_29 AC 79 ms
15,032 KB
testcase_30 AC 78 ms
15,268 KB
testcase_31 AC 78 ms
15,148 KB
testcase_32 AC 77 ms
15,248 KB
testcase_33 AC 79 ms
15,644 KB
testcase_34 AC 79 ms
15,636 KB
testcase_35 AC 78 ms
15,652 KB
testcase_36 AC 79 ms
15,656 KB
testcase_37 AC 80 ms
15,844 KB
testcase_38 AC 89 ms
23,248 KB
testcase_39 AC 96 ms
26,596 KB
testcase_40 AC 122 ms
39,176 KB
testcase_41 AC 106 ms
31,868 KB
testcase_42 AC 92 ms
25,204 KB
testcase_43 AC 93 ms
25,480 KB
testcase_44 AC 169 ms
64,744 KB
testcase_45 AC 85 ms
20,308 KB
testcase_46 AC 99 ms
29,420 KB
testcase_47 AC 166 ms
64,216 KB
testcase_48 AC 136 ms
42,756 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
  MOD = 1000000000

  def initialize
    n = gets.to_i
    m = gets.to_i

    puts m.combination((n-m*1000*(n/m/1000))/1000) % MOD
  end
end

Yukicoder.new
0