結果
| 問題 |
No.420 mod2漸化式
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2016-09-09 22:38:33 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 1,000 ms |
| コード長 | 285 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-12-24 10:58:18 |
| 合計ジャッジ時間 | 4,853 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 |
コンパイルメッセージ
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 [1,0] if x == 0
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
puts (solve gets.to_i).join(' ')
tubo28