結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2019-03-30 19:23:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 1,594 bytes |
コンパイル時間 | 830 ms |
コンパイル使用メモリ | 96,724 KB |
実行使用メモリ | 34,688 KB |
最終ジャッジ日時 | 2024-11-16 10:13:08 |
合計ジャッジ時間 | 1,624 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<algorithm> #include<complex> #include<ctype.h> #include<iomanip> #include<iostream> #include<fstream> #include<map> #include<math.h> #include<numeric> #include<queue> #include<set> #include<stack> #include<stdio.h> #include<string> #include<string> #include<vector> using namespace std; typedef long long ll; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<<endl #define p2(s, t) cout << (s) << " " << (t) << endl #define br() p("") #define pn(s) cout << (#s) << " " << (s) << endl #define p_yes() p("Yes") #define p_no() p("No") const ll mod = 1e9 + 7; const ll inf = 1e18; const int N_MAX = 1000010; ll dp[N_MAX][2][2]; // i 番目 // j 前回に出した手 // k 今回に出した手 int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin >> N; if(N==1){ p(1); return 0; } // 0 ken // 1 pa dp[0][0][0] = 0; dp[0][0][1] = 0; dp[0][1][0] = 0; dp[0][1][1] = 0; dp[1][0][0] = 1; dp[1][0][1] = 1; dp[1][1][0] = 0; // pa ken dp[1][1][1] = 0; FOR(i, 2, N){ // ken ken dp[i][0][0] = dp[i-1][1][0]; dp[i][0][0] %= mod; // ken pa dp[i][0][1] = dp[i-1][0][0] + dp[i-1][1][0]; dp[i][0][1] %= mod; // pa ken dp[i][1][0] = dp[i-1][0][1]; dp[i][1][0] %= mod; dp[i][1][1] = 0; } ll sum = 0; sum += dp[N-1][0][0]; sum %= mod; sum += dp[N-1][0][1]; sum %= mod; sum += dp[N-1][1][0]; sum %= mod; p(sum); return 0; }