結果
| 問題 |
No.420 mod2漸化式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-18 02:08:05 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 504 bytes |
| コンパイル時間 | 135 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-11-26 03:30:35 |
| 合計ジャッジ時間 | 3,962 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 WA * 3 |
コンパイルメッセージ
Main.rb:22: warning: `-' after local variable or literal is interpreted as binary operator Main.rb:22: 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
def cal(x)
if x > 31 || x == 0
puts "#{1} #{0}"
return
end
n = 31.combination(x)
sum = (2**31 -1) * 30.combination(x-1)
puts "#{n} #{sum}"
end
cal(x)