結果

問題 No.533 Mysterious Stairs
ユーザー pluto77pluto77
提出日時 2017-07-22 09:20:57
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,026 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 212,864 KB
最終ジャッジ日時 2024-04-17 15:25:18
合計ジャッジ時間 8,459 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,144 KB
testcase_01 AC 10 ms
6,144 KB
testcase_02 AC 10 ms
6,272 KB
testcase_03 AC 10 ms
6,272 KB
testcase_04 AC 10 ms
6,272 KB
testcase_05 AC 11 ms
6,144 KB
testcase_06 AC 9 ms
6,272 KB
testcase_07 AC 11 ms
6,144 KB
testcase_08 AC 14 ms
6,272 KB
testcase_09 AC 11 ms
6,272 KB
testcase_10 AC 12 ms
6,400 KB
testcase_11 AC 10 ms
6,272 KB
testcase_12 AC 10 ms
6,400 KB
testcase_13 AC 12 ms
6,528 KB
testcase_14 AC 11 ms
6,528 KB
testcase_15 AC 13 ms
6,656 KB
testcase_16 AC 15 ms
6,912 KB
testcase_17 AC 19 ms
7,296 KB
testcase_18 AC 22 ms
7,808 KB
testcase_19 AC 24 ms
8,320 KB
testcase_20 AC 191 ms
29,056 KB
testcase_21 AC 214 ms
31,488 KB
testcase_22 AC 712 ms
85,248 KB
testcase_23 AC 2,026 ms
210,432 KB
testcase_24 AC 2,007 ms
212,864 KB
testcase_25 AC 180 ms
29,312 KB
testcase_26 AC 1,542 ms
184,320 KB
testcase_27 AC 414 ms
58,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_533
import sys

mod=10**9+7
n=int(raw_input())
if n==1 or n==2:
 print 1
 sys.exit()
dp=[[0 for i in xrange(3)] for j in xrange(n+1)]
dp[1][0]=dp[2][1]=dp[3][0]=dp[3][1]=dp[3][2]=1
for i in xrange(4,n+1):
 dp[i][0]=(dp[i-1][1]+dp[i-1][2])%mod
 dp[i][1]=(dp[i-2][0]+dp[i-2][2])%mod
 dp[i][2]=(dp[i-3][0]+dp[i-3][1])%mod
print (sum(dp[n]))%mod
0