結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2015-12-24 12:07:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 23 ms / 1,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 84,824 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 22:36:59 |
合計ジャッジ時間 | 1,463 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<iostream>#include<sstream>#include<cstdio>#include<cstring>#include<string>#include<vector>#include<list>#include<queue>#include<stack>#include<utility>#include <fstream>#include<set>#include<map>#include<cctype>#include<cmath>#include<algorithm>#include <numeric>using namespace std;#define RALL(x) (x).rbegin(),(x).rend()#define ALL(x) (x).begin(),(x).end()#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)#define clr(a) memset((a), 0 ,sizeof(a))#define found(s,e) ((s).find(e)!=(s).end())typedef pair<int,int> P;typedef vector<pair<int,string> > pii;typedef map<string,int> mdi;const int mod=1000000007;int main(){int n;vector<int> dp(3);dp[0]=1;cin >> n;for(int i=0;i<n;i++){vector<int> dp2(3);for(int j=0;j<3;j++){if(j>0){dp2[0]+=dp[j];dp2[0]%=mod;}if(j<2){dp2[j+1]+=dp[j];dp2[j+1]%=mod;}}dp.swap(dp2);}int ans=0;for(int i=0;i<3;i++){ans+=dp[i];ans%=mod;}cout << ans << endl;return 0;}