結果

問題 No.533 Mysterious Stairs
ユーザー mine691mine691
提出日時 2018-09-01 16:20:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 64,460 KB
実行使用メモリ 20,840 KB
最終ジャッジ日時 2023-10-19 03:32:43
合計ジャッジ時間 2,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
20,832 KB
testcase_01 AC 8 ms
20,832 KB
testcase_02 AC 8 ms
20,832 KB
testcase_03 AC 8 ms
20,832 KB
testcase_04 AC 8 ms
20,832 KB
testcase_05 AC 8 ms
20,832 KB
testcase_06 AC 8 ms
20,832 KB
testcase_07 AC 8 ms
20,832 KB
testcase_08 AC 9 ms
20,832 KB
testcase_09 AC 9 ms
20,832 KB
testcase_10 AC 8 ms
20,832 KB
testcase_11 AC 8 ms
20,832 KB
testcase_12 AC 8 ms
20,832 KB
testcase_13 AC 8 ms
20,832 KB
testcase_14 AC 8 ms
20,832 KB
testcase_15 AC 9 ms
20,832 KB
testcase_16 AC 8 ms
20,832 KB
testcase_17 AC 8 ms
20,832 KB
testcase_18 AC 8 ms
20,832 KB
testcase_19 AC 8 ms
20,832 KB
testcase_20 AC 9 ms
20,832 KB
testcase_21 AC 9 ms
20,832 KB
testcase_22 AC 12 ms
20,832 KB
testcase_23 AC 18 ms
20,832 KB
testcase_24 AC 17 ms
20,832 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