結果

問題 No.533 Mysterious Stairs
ユーザー mikan765mikan765
提出日時 2017-07-11 13:45:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 69,600 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-16 16:54:28
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 4 ms
5,504 KB
testcase_22 AC 8 ms
9,728 KB
testcase_23 AC 20 ms
18,944 KB
testcase_24 AC 19 ms
19,200 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
int dp[1000001][4];
int main() {
	int n;

	// 標準入力から、空白や改行で区切られた整数と文字列を読み込む。
	cin >> n;
	dp[0][0]=1;dp[0][1]=0;dp[0][2]=0;dp[0][3]=0;
	dp[1][0]=1;dp[1][1]=1;dp[1][2]=0;dp[1][3]=0;
	dp[2][0]=1;dp[2][1]=0;dp[2][2]=1;dp[2][3]=0;
	for(int i=3;i<=n;i++){
		for(int j=1;j<4;j++){
			dp[i][j]=(dp[i-j][0]-dp[i-j][j])%1000000007;
		}
		dp[i][0]=(dp[i][1]+dp[i][2]+dp[i][3]);
	}
    // 整数と文字列を空白で区切って、標準出力に書き出す。
    cout << dp[n][0]%1000000007;
    return 0;
}
0