結果

問題 No.533 Mysterious Stairs
ユーザー mine691mine691
提出日時 2018-09-01 12:04:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 64,432 KB
実行使用メモリ 20,804 KB
最終ジャッジ日時 2023-10-13 15:10:07
合計ジャッジ時間 2,689 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
20,544 KB
testcase_01 AC 7 ms
20,552 KB
testcase_02 AC 7 ms
20,544 KB
testcase_03 AC 7 ms
20,520 KB
testcase_04 AC 7 ms
20,568 KB
testcase_05 AC 8 ms
20,512 KB
testcase_06 AC 7 ms
20,568 KB
testcase_07 AC 7 ms
20,508 KB
testcase_08 AC 7 ms
20,544 KB
testcase_09 AC 8 ms
20,600 KB
testcase_10 AC 7 ms
20,656 KB
testcase_11 AC 7 ms
20,516 KB
testcase_12 AC 8 ms
20,524 KB
testcase_13 AC 8 ms
20,568 KB
testcase_14 AC 7 ms
20,508 KB
testcase_15 AC 7 ms
20,628 KB
testcase_16 AC 8 ms
20,548 KB
testcase_17 AC 8 ms
20,552 KB
testcase_18 AC 7 ms
20,560 KB
testcase_19 AC 8 ms
20,624 KB
testcase_20 AC 8 ms
20,692 KB
testcase_21 AC 8 ms
20,504 KB
testcase_22 AC 12 ms
20,512 KB
testcase_23 AC 16 ms
20,544 KB
testcase_24 AC 18 ms
20,560 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int INF=1e9+7;

int main() {
	int n;
	cin >> n;
	int dp[1100000][4];
	for(int i=0;i<1100000;i++){
	    for(int j=0;j<4;j++)dp[i][j]=0;
	}
	dp[1][1]=1;
	dp[2][2]=1;
	dp[3][3]=1;
	for (int i = 1;i <= n;i++) {
		dp[i + 1][1] += (dp[i][2] + dp[i][3])%INF;
		dp[i + 2][2] += (dp[i][1] + dp[i][3])%INF;
		dp[i + 3][3] += (dp[i][1] + dp[i][2])%INF;
	}
	cout << (dp[n][1] + dp[n][2] + dp[n][3])%INF << endl;
}
0