結果

問題 No.314 ケンケンパ
ユーザー NekosyndromeNekosyndrome
提出日時 2015-12-11 21:53:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 795 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 143,632 KB
実行使用メモリ 27,140 KB
最終ジャッジ日時 2023-10-13 11:26:02
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
27,092 KB
testcase_01 AC 9 ms
26,924 KB
testcase_02 AC 9 ms
26,868 KB
testcase_03 AC 9 ms
26,872 KB
testcase_04 AC 9 ms
26,952 KB
testcase_05 AC 9 ms
26,972 KB
testcase_06 AC 9 ms
26,908 KB
testcase_07 AC 9 ms
26,896 KB
testcase_08 AC 9 ms
26,908 KB
testcase_09 AC 9 ms
27,008 KB
testcase_10 AC 9 ms
26,908 KB
testcase_11 AC 9 ms
27,012 KB
testcase_12 AC 9 ms
26,876 KB
testcase_13 AC 9 ms
26,928 KB
testcase_14 AC 9 ms
27,048 KB
testcase_15 AC 9 ms
27,140 KB
testcase_16 AC 10 ms
26,904 KB
testcase_17 AC 9 ms
26,956 KB
testcase_18 AC 12 ms
26,996 KB
testcase_19 AC 16 ms
26,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1000005
#define MOD 1000000007
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n;
LL dp[M][3];
int main()
{
	while(~scanf("%d",&n))
	{
		MSET(dp,0);
		dp[0][0]=1;
		REP(i,1,n)REP(j,0,2)
		{
			if(j==0) dp[i][j] = dp[i-1][1]+dp[i-1][2];
			else dp[i][j] = dp[i-1][j-1];
			dp[i][j] %= MOD;
		}

		printf("%lld\n", (dp[n][0]+dp[n][1]+dp[n][2])%MOD);
	}
	return 0;
}
0