結果

問題 No.533 Mysterious Stairs
ユーザー misora192misora192
提出日時 2020-05-16 08:36:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 782 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 167,892 KB
実行使用メモリ 34,856 KB
最終ジャッジ日時 2023-10-21 19:57:53
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 6 ms
7,076 KB
testcase_21 AC 6 ms
7,464 KB
testcase_22 AC 11 ms
15,572 KB
testcase_23 AC 22 ms
34,468 KB
testcase_24 AC 22 ms
34,856 KB
testcase_25 AC 6 ms
7,104 KB
testcase_26 AC 19 ms
30,520 KB
testcase_27 AC 9 ms
11,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;

	ll MOD = 1e9 + 7;

	ll dp[n+5][4];
	rep(i, n+5) rep(j, 4) dp[i][j] = 0;
	dp[1][1] = dp[2][2] = dp[3][3] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 3; j++){
			if(j != 1) {dp[i+j][j] += dp[i][1]; dp[i+j][j] %= MOD;}
			if(j != 2) {dp[i+j][j] += dp[i][2]; dp[i+j][j] %= MOD;}
			if(j != 3) {dp[i+j][j] += dp[i][3]; dp[i+j][j] %= MOD;}
		}
	}

	cout << (dp[n][1] + dp[n][2] + dp[n][3]) % MOD << endl;
}
0