結果

問題 No.533 Mysterious Stairs
ユーザー maimai
提出日時 2017-06-23 01:30:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,391 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 74,752 KB
最終ジャッジ日時 2024-04-15 00:46:35
合計ジャッジ時間 11,972 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
13,056 KB
testcase_01 AC 89 ms
13,184 KB
testcase_02 AC 93 ms
13,056 KB
testcase_03 AC 94 ms
13,184 KB
testcase_04 AC 91 ms
13,184 KB
testcase_05 AC 94 ms
12,928 KB
testcase_06 AC 95 ms
13,056 KB
testcase_07 AC 88 ms
12,928 KB
testcase_08 AC 91 ms
13,184 KB
testcase_09 AC 93 ms
13,184 KB
testcase_10 AC 90 ms
12,928 KB
testcase_11 AC 93 ms
13,056 KB
testcase_12 AC 93 ms
13,184 KB
testcase_13 AC 90 ms
12,928 KB
testcase_14 AC 91 ms
13,056 KB
testcase_15 AC 92 ms
13,056 KB
testcase_16 AC 95 ms
13,184 KB
testcase_17 AC 95 ms
13,184 KB
testcase_18 AC 99 ms
13,184 KB
testcase_19 AC 100 ms
13,312 KB
testcase_20 AC 190 ms
19,712 KB
testcase_21 AC 206 ms
21,888 KB
testcase_22 AC 699 ms
34,304 KB
testcase_23 AC 2,341 ms
66,048 KB
testcase_24 AC 2,391 ms
74,752 KB
testcase_25 AC 193 ms
20,352 KB
testcase_26 AC 2,093 ms
54,528 KB
testcase_27 AC 405 ms
28,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'matrix'

# 
# オーバーキル解法.O(logN)
# 途中計算で剰余取らずに多倍長でごリ押すため,遅くなる.
# 

MOD = 1000000007

n = gets.to_i-1

my_nice_matrix = Matrix[ \
                 [0,1,1,0,0,0], \
                 [0,0,0,1,0,0], \
                 [0,0,0,0,1,0], \
                 [1,0,1,0,0,0], \
                 [0,0,0,0,0,1], \
                 [1,1,0,0,0,0]]



status = Matrix.column_vector([1,0,0,1,0,1])

status = (my_nice_matrix**n)*status

p (status[0,0]%MOD + status[1,0]%MOD + status[2,0]%MOD)%MOD
0