結果

問題 No.533 Mysterious Stairs
ユーザー ldsybldsyb
提出日時 2017-06-24 00:03:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 384 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 64,628 KB
実行使用メモリ 34,928 KB
最終ジャッジ日時 2024-04-15 01:11:50
合計ジャッジ時間 1,290 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 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,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 5 ms
7,040 KB
testcase_21 AC 5 ms
7,352 KB
testcase_22 AC 9 ms
15,496 KB
testcase_23 AC 18 ms
34,452 KB
testcase_24 AC 19 ms
34,928 KB
testcase_25 AC 5 ms
7,040 KB
testcase_26 AC 15 ms
30,496 KB
testcase_27 AC 6 ms
11,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int64_t dp[n + 1][4]{};
	dp[1][1] = 1;
	if(1 < n) dp[2][2] = 1;
	if(2 < n) dp[3][3] = 1;
	for(int i = 3; i <= n; i++) for(int j = 1; j <= 3; j++) (dp[i][j] += dp[i - j][1] + dp[i - j][2] + dp[i - j][3] - dp[i - j][j]) %= int64_t(1e9 + 7);
	cout << (dp[n][1] + dp[n][2] + dp[n][3]) % int64_t(1e9 + 7) << endl;
}
0