結果

問題 No.533 Mysterious Stairs
ユーザー Mr.SpockMr.Spock
提出日時 2020-12-26 22:21:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 171,140 KB
実行使用メモリ 57,884 KB
最終ジャッジ日時 2023-10-25 07:08:55
合計ジャッジ時間 3,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 12 ms
9,196 KB
testcase_21 AC 13 ms
9,988 KB
testcase_22 AC 33 ms
24,040 KB
testcase_23 AC 79 ms
57,092 KB
testcase_24 AC 80 ms
57,884 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<vector<int>>dp(n + 4, vector<int>(4, 0));
	dp[1][0] = 1;
	dp[2][1] = 1;
	dp[3][0] = 1;
	dp[3][1] = 1;
	dp[3][2] = 1;
	for (int i = 4; i <= n; i++) {
		dp[i][0] = dp[i - 1][1] + dp[i - 1][2];
		dp[i][0] %= mod;
		dp[i][1] = dp[i - 2][0] + dp[i - 2][2];
		dp[i][1] %= mod;
		dp[i][2] = dp[i - 3][1] + dp[i - 3][0];
		dp[i][2] %= mod;
	}
	cout << (dp[n][0] + dp[n][1] + dp[n][2]) % mod << endl;
}
0