結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 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
7,040 KB
testcase_21 AC 4 ms
7,424 KB
testcase_22 AC 8 ms
15,488 KB
testcase_23 AC 18 ms
34,420 KB
testcase_24 AC 18 ms
34,816 KB
testcase_25 AC 4 ms
7,040 KB
testcase_26 AC 16 ms
30,336 KB
testcase_27 AC 6 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int64_t dp[n + 1][4]{};
	dp[1][1] = dp[2][2] = 1;
	if(1 < 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