結果

問題 No.420 mod2漸化式
ユーザー shi-moshi-mo
提出日時 2016-10-20 23:56:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 342 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 11,424 KB
実行使用メモリ 15,460 KB
最終ジャッジ日時 2023-08-26 00:42:35
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,408 KB
testcase_01 AC 85 ms
15,404 KB
testcase_02 AC 84 ms
15,276 KB
testcase_03 AC 84 ms
15,432 KB
testcase_04 AC 84 ms
15,416 KB
testcase_05 AC 84 ms
15,252 KB
testcase_06 AC 83 ms
15,256 KB
testcase_07 AC 83 ms
15,168 KB
testcase_08 AC 83 ms
15,144 KB
testcase_09 AC 83 ms
15,276 KB
testcase_10 AC 84 ms
15,380 KB
testcase_11 AC 83 ms
15,376 KB
testcase_12 AC 83 ms
15,356 KB
testcase_13 AC 82 ms
15,232 KB
testcase_14 AC 84 ms
15,416 KB
testcase_15 AC 83 ms
15,412 KB
testcase_16 AC 83 ms
15,176 KB
testcase_17 AC 84 ms
15,400 KB
testcase_18 AC 84 ms
15,424 KB
testcase_19 AC 86 ms
15,416 KB
testcase_20 AC 83 ms
15,312 KB
testcase_21 AC 84 ms
15,440 KB
testcase_22 AC 83 ms
15,408 KB
testcase_23 AC 82 ms
15,192 KB
testcase_24 AC 83 ms
15,336 KB
testcase_25 AC 82 ms
15,124 KB
testcase_26 AC 84 ms
15,168 KB
testcase_27 AC 84 ms
15,268 KB
testcase_28 AC 84 ms
15,260 KB
testcase_29 AC 84 ms
15,424 KB
testcase_30 AC 85 ms
15,132 KB
testcase_31 AC 84 ms
15,160 KB
testcase_32 AC 83 ms
15,408 KB
testcase_33 AC 85 ms
15,256 KB
testcase_34 AC 85 ms
15,460 KB
testcase_35 AC 85 ms
15,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'bigdecimal'

x = gets.to_i

if 0 == x
  puts '1 0'
  exit 0
end

if 31 < x
  puts '0 0'
  exit 0
end

def c(n, k)
  r = BigDecimal(1)
  1.upto(n){|i| r *= BigDecimal(i) }
  1.upto(k){|i| r /= BigDecimal(i) }
  1.upto(n-k){|i| r /= BigDecimal(i) }
  r
end

cnt = c(31, x)
sum = (2**31 - 1) * c(30, x-1)

puts "#{cnt.to_i} #{sum.to_i}"
0