結果

問題 No.420 mod2漸化式
コンテスト
ユーザー kk
提出日時 2016-11-18 01:57:52
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
RE  
実行時間 -
コード長 396 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 217 ms
コンパイル使用メモリ 9,216 KB
実行使用メモリ 123,308 KB
最終ジャッジ日時 2026-05-20 15:19:39
合計ジャッジ時間 5,386 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31 RE * 2 TLE * 1 -- * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:18: warning: '-' after local variable or literal is interpreted as binary operator even though it seems like unary operator
Syntax OK

ソースコード

diff #
raw source code

class Integer
    def factorial
        return 1 if self == 0
        (1..self).inject(:*)
    end

    def permutation(k)
        self.factorial/(self-k).factorial
    end

    def combination(k)
        self.factorial/((self-k).factorial*k.factorial)
    end
end
x = gets.to_i
    puts "0 0" if x > 31
    n = 31.combination(x)
    sum = (2**31 -1) * 30.combination(x-1)
    puts "#{n} #{sum}"
0