結果

問題 No.533 Mysterious Stairs
ユーザー 👑 obakyanobakyan
提出日時 2019-04-14 20:41:09
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 27,356 KB
最終ジャッジ日時 2023-10-19 15:38:23
合計ジャッジ時間 1,609 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 6 ms
5,748 KB
testcase_21 AC 7 ms
5,748 KB
testcase_22 AC 19 ms
15,012 KB
testcase_23 AC 38 ms
27,356 KB
testcase_24 AC 39 ms
27,356 KB
testcase_25 AC 7 ms
5,748 KB
testcase_26 AC 37 ms
27,356 KB
testcase_27 AC 12 ms
8,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
n = io.read("*n")
t = {{}, {}, {}}
t[1][1], t[1][2], t[1][3] = 1, 0, 1
t[2][1], t[2][2], t[2][3] = 0, 1, 1
t[3][1], t[3][2], t[3][3] = 0, 0, 1
for i = 4, n do
    t[1][i] = (t[3][i - 1] + t[2][i - 1]) % mod
    t[2][i] = (t[3][i - 2] + t[1][i - 2]) % mod
    t[3][i] = (t[2][i - 3] + t[1][i - 3]) % mod
end
ret = (t[1][n] + t[2][n]) % mod
ret = (ret + t[3][n]) % mod
print(ret) 
0