結果

問題 No.129 お年玉(2)
ユーザー siman
提出日時 2016-03-23 00:59:09
言語 Ruby
(3.4.1)
結果
AC  
実行時間 203 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 53,504 KB
最終ジャッジ日時 2024-11-28 00:23:52
合計ジャッジ時間 8,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
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