結果

問題 No.533 Mysterious Stairs
ユーザー myantamyanta
提出日時 2017-06-23 23:52:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 39,296 KB
実行使用メモリ 72,996 KB
最終ジャッジ日時 2024-04-15 01:09:21
合計ジャッジ時間 1,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 14 ms
10,624 KB
testcase_21 AC 13 ms
11,648 KB
testcase_22 AC 39 ms
29,720 KB
testcase_23 AC 104 ms
72,128 KB
testcase_24 AC 102 ms
72,996 KB
testcase_25 AC 14 ms
10,752 KB
testcase_26 AC 88 ms
63,356 KB
testcase_27 AC 27 ms
20,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<vector>


using namespace std;

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;

#define MOD 1000000007

int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		if(n<=2)
		{
			printf("1\n");
			continue;
		}

		vvll dp(n+3);
		for(auto&dpe:dp) dpe.assign(4, 0);

		dp[3][3]=1;
		dp[2][2]=1;
		dp[1][1]=1;

		for(int i=1;i<n;i++)
		{
			for(int j=1;j<=3;j++)
			{
				for(int k=1;k<=3;k++)
				{
					if(j==k) continue;
					dp[i+k][k]=(dp[i+k][k]+dp[i][j])%MOD;
				}
			}
		}

		ll ans=0;
		for(int i=1;i<=3;i++)
		{
			ans=(ans+dp[n][i])%MOD;
		}
		printf("%d\n", (int)ans);
	}

	return 0;
}
0