結果
| 問題 | No.314 ケンケンパ |
| コンテスト | |
| ユーザー |
Lay_ec
|
| 提出日時 | 2015-12-07 20:46:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 821 bytes |
| 記録 | |
| コンパイル時間 | 629 ms |
| コンパイル使用メモリ | 79,144 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 18:29:44 |
| 合計ジャッジ時間 | 1,359 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
long long ken[2][3],pa[2];
const long long mod=1000000007;
int main()
{
int n;
cin>>n;
ken[1][1]=1;
int cur=1;
for(int i=1;i<n;i++){
int tar=cur^1;
ken[tar][0]=ken[tar][1]=ken[tar][2]=0;
pa[tar]=0;
for(int j=1;j<3;j++){
//ケン->ケン
if(j!=2) ken[tar][j+1]=(ken[tar][j+1]+ken[cur][j])%mod;
//ケン->パ
pa[tar]=(pa[tar]+ken[cur][j])%mod;
}
//パ->ケン
ken[tar][1]=(ken[tar][1]+pa[cur]);
cur=tar;
}
long long res=(ken[cur][0]+ken[cur][1]+ken[cur][2]+pa[cur])%mod;
cout<<res<<endl;
return 0;
}
Lay_ec