結果

問題 No.533 Mysterious Stairs
ユーザー finefine
提出日時 2017-06-23 22:30:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 502 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 164,116 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-04-15 00:53:13
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 8 ms
6,944 KB
testcase_21 AC 8 ms
7,296 KB
testcase_22 AC 21 ms
15,488 KB
testcase_23 AC 51 ms
34,304 KB
testcase_24 AC 53 ms
34,560 KB
testcase_25 AC 8 ms
7,168 KB
testcase_26 AC 45 ms
30,464 KB
testcase_27 AC 15 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll dp[1000010][4];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	dp[1][1] = 1;
	dp[2][2] = 1;
	dp[3][3] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 3; j++) {
			if (i < j) break;
			for (int k = 1; k <= 3; k++) {
				if (k == j) continue;
				(dp[i][j] += dp[i - j][k]) %= MOD;
			}
		}
	}
	cout << (dp[n][1] + dp[n][2] + dp[n][3]) % MOD << endl;
	return 0;
}
0