結果

問題 No.533 Mysterious Stairs
ユーザー mikan765mikan765
提出日時 2017-07-11 13:48:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,087 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 193,024 KB
実行使用メモリ 34,816 KB
最終ジャッジ日時 2024-04-16 16:59:24
合計ジャッジ時間 2,977 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll dp[1000001][4];
int main() {
	int n;

	// 標準入力から、空白や改行で区切られた整数と文字列を読み込む。
	cin >> n;
	dp[0][0]=1;dp[0][1]=0;dp[0][2]=0;dp[0][3]=0;
	dp[1][0]=1;dp[1][1]=1;dp[1][2]=0;dp[1][3]=0;
	dp[2][0]=1;dp[2][1]=0;dp[2][2]=1;dp[2][3]=0;
	for(int i=3;i<=n;i++){
		for(int j=1;j<4;j++){
			dp[i][j]=(dp[i-j][0]-dp[i-j][j])%1000000007;
		}
		dp[i][0]=(dp[i][1]+dp[i][2]+dp[i][3]);
	}
    // 整数と文字列を空白で区切って、標準出力に書き出す。
    cout << dp[n][0]%1000000007;
    return 0;
}
0