結果
| 問題 | No.420 mod2漸化式 |
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2016-09-09 22:37:46 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 282 bytes |
| 記録 | |
| コンパイル時間 | 308 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-11-16 10:31:11 |
| 合計ジャッジ時間 | 4,906 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 34 RE * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
def nCr n,r
res = 1
r.times { |i| res *= n-i }
r.times { |i| res /= i+1 }
res
end
def solve x
return [0,0] if x > 31
cnt = nCr(31, x)
sum = 31.times.map { |i| (2**i) * nCr(30, x-1) }.inject(:+)
[cnt, sum]
end
x = gets.to_i
raise if x == 0
puts (solve x).join(' ')
tubo28