結果

問題 No.533 Mysterious Stairs
ユーザー e869120e869120
提出日時 2017-06-23 22:33:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 506 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 78,680 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-04-15 00:53:34
合計ジャッジ時間 1,761 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 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,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,948 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 9 ms
6,940 KB
testcase_22 AC 24 ms
9,600 KB
testcase_23 AC 56 ms
18,944 KB
testcase_24 AC 57 ms
19,072 KB
testcase_25 AC 9 ms
6,944 KB
testcase_26 AC 49 ms
17,024 KB
testcase_27 AC 16 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<functional>
using namespace std;
int dp[1000009][4], mod = 1000000007, n;
int main() {
	dp[0][0] = 1; cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 1; k <= 3; k++) {
				if (j != k) { dp[i + k][k] += dp[i][j]; dp[i + k][k] %= mod; }
			}
		}
	}
	cout << (1LL * dp[n][0] + 1LL * dp[n][1] + 1LL * dp[n][2] + 1LL * dp[n][3]) % mod << endl;
	return 0;
}
0