結果
問題 | No.314 ケンケンパ |
ユーザー | Nekosyndrome |
提出日時 | 2015-12-11 21:53:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 16 ms / 1,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 1,221 ms |
コンパイル使用メモリ | 156,944 KB |
実行使用メモリ | 27,136 KB |
最終ジャッジ日時 | 2024-09-15 08:25:14 |
合計ジャッジ時間 | 2,227 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#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; }