結果

問題 No.53 悪の漸化式
ユーザー wotsushiwotsushi
提出日時 2017-03-12 15:01:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 192 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 16,284 KB
最終ジャッジ日時 2023-09-12 11:58:56
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
15,672 KB
testcase_01 AC 99 ms
15,844 KB
testcase_02 AC 96 ms
15,828 KB
testcase_03 AC 96 ms
15,868 KB
testcase_04 AC 96 ms
16,140 KB
testcase_05 AC 97 ms
16,284 KB
testcase_06 AC 97 ms
16,032 KB
testcase_07 AC 96 ms
16,092 KB
testcase_08 AC 97 ms
16,040 KB
testcase_09 AC 97 ms
16,236 KB
testcase_10 AC 97 ms
16,176 KB
testcase_11 AC 97 ms
16,000 KB
testcase_12 AC 96 ms
15,996 KB
testcase_13 AC 97 ms
16,224 KB
testcase_14 AC 96 ms
16,084 KB
testcase_15 AC 97 ms
16,020 KB
testcase_16 AC 96 ms
16,044 KB
testcase_17 AC 96 ms
16,096 KB
testcase_18 AC 97 ms
16,080 KB
testcase_19 AC 98 ms
15,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'matrix'

N = gets.to_i
A = Matrix[[19, -12], [4, 0]]
ans = if N == 0
        4
      else
        B = A**(N - 1)
        (3 * B[0, 0] + 4 * B[0, 1]) / 4.0**(N - 1)
      end
puts ans
0