結果

問題 No.533 Mysterious Stairs
ユーザー chocoruskchocorusk
提出日時 2018-10-17 06:39:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 680 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 90,564 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-20 20:43:26
合計ジャッジ時間 2,254 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
34,560 KB
testcase_01 AC 24 ms
34,560 KB
testcase_02 AC 22 ms
34,688 KB
testcase_03 AC 24 ms
34,688 KB
testcase_04 AC 23 ms
34,560 KB
testcase_05 AC 23 ms
34,560 KB
testcase_06 AC 24 ms
34,688 KB
testcase_07 AC 23 ms
34,560 KB
testcase_08 AC 23 ms
34,560 KB
testcase_09 AC 22 ms
34,560 KB
testcase_10 AC 23 ms
34,560 KB
testcase_11 AC 22 ms
34,688 KB
testcase_12 AC 21 ms
34,688 KB
testcase_13 AC 23 ms
34,560 KB
testcase_14 AC 23 ms
34,688 KB
testcase_15 AC 23 ms
34,560 KB
testcase_16 AC 23 ms
34,688 KB
testcase_17 AC 23 ms
34,560 KB
testcase_18 AC 23 ms
34,560 KB
testcase_19 AC 24 ms
34,688 KB
testcase_20 AC 25 ms
34,688 KB
testcase_21 AC 24 ms
34,560 KB
testcase_22 AC 29 ms
34,560 KB
testcase_23 AC 38 ms
34,560 KB
testcase_24 AC 38 ms
34,560 KB
testcase_25 AC 25 ms
34,560 KB
testcase_26 AC 36 ms
34,560 KB
testcase_27 AC 28 ms
34,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
	cin>>n;
	ll dp[1000001][4]={};
	dp[0][0]=1;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=3; j++){
			if(i<j) continue;
			for(int k=0; k<=3; k++){
				if(j==k) continue;
				dp[i][j]+=dp[i-j][k];
			}
			dp[i][j]%=MOD;
		}
	}
	cout<<(dp[n][1]+dp[n][2]+dp[n][3])%MOD<<endl;
	return 0;
}
0