結果

問題 No.420 mod2漸化式
ユーザー tubo28
提出日時 2016-09-09 22:36:24
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 260 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-11-16 10:29:25
合計ジャッジ時間 4,179 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 34 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

puts (solve gets.to_i).join(' ')
0