結果

問題 No.533 Mysterious Stairs
ユーザー gyu-dongyu-don
提出日時 2017-08-07 14:41:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,081 ms / 5,000 ms
コード長 382 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 128,516 KB
最終ジャッジ日時 2024-04-20 04:40:10
合計ジャッジ時間 5,601 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,880 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 24 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 25 ms
10,880 KB
testcase_09 AC 24 ms
10,752 KB
testcase_10 AC 24 ms
10,752 KB
testcase_11 AC 25 ms
10,752 KB
testcase_12 AC 24 ms
10,880 KB
testcase_13 AC 25 ms
10,752 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 25 ms
10,880 KB
testcase_16 AC 27 ms
11,136 KB
testcase_17 AC 31 ms
11,392 KB
testcase_18 AC 32 ms
11,776 KB
testcase_19 AC 34 ms
12,160 KB
testcase_20 AC 142 ms
23,940 KB
testcase_21 AC 159 ms
25,476 KB
testcase_22 AC 451 ms
55,936 KB
testcase_23 AC 1,021 ms
126,976 KB
testcase_24 AC 1,081 ms
128,516 KB
testcase_25 AC 136 ms
24,064 KB
testcase_26 AC 932 ms
112,128 KB
testcase_27 AC 294 ms
40,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input().strip())
div = 10**9 + 7
if n <= 1:
    print(1)
    raise SystemExit
elif n == 2:
    print(1)
    raise SystemExit

t1 = [1, 1, 0]
t2 = [0, 0, 1]
t3 = [0, 0, 0]

for i in range(3, n + 1):
    t1.append((t2[i - 1] + t3[i - 1]) % div)
    t2.append((t1[i - 2] + t3[i - 2]) % div)
    t3.append((t1[i - 3] + t2[i - 3]) % div)

print((t1[-1] + t2[-1] + t3[-1]) % div)
0