結果
問題 |
No.420 mod2漸化式
|
ユーザー |
|
提出日時 | 2016-11-18 01:57:52 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 396 bytes |
コンパイル時間 | 39 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 110,792 KB |
最終ジャッジ日時 | 2024-11-26 03:30:13 |
合計ジャッジ時間 | 7,940 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 RE * 2 TLE * 2 |
コンパイルメッセージ
Main.rb:18: warning: `-' after local variable or literal is interpreted as binary operator Main.rb:18: warning: even though it seems like unary operator Syntax OK
ソースコード
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}"