結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-05-03 07:52:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 470 bytes |
| コンパイル時間 | 1,676 ms |
| コンパイル使用メモリ | 167,376 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 06:59:43 |
| 合計ジャッジ時間 | 2,444 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
const int mod=1e9+7;
ll dp[2][3];
int main(){
int N;
cin>>N;
dp[0][0]=1;
dp[0][1]=0;
dp[0][2]=0;
int from=0,to=1;
REP(i,0,N){
dp[to][0]=(dp[from][1]+dp[from][2])%mod;//パ
dp[to][1]=dp[from][0];//ケン1
dp[to][2]=dp[from][1];//ケン2
swap(from,to);
}
p((dp[N%2][0]+dp[N%2][1]+dp[N%2][2])%mod);
return 0;
}
dnish