結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-02-26 18:31:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 1,017 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 73,972 KB |
実行使用メモリ | 26,764 KB |
最終ジャッジ日時 | 2024-09-22 14:00:09 |
合計ジャッジ時間 | 1,347 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <cstdio>#include <iostream>#include <algorithm>#include <complex>#include <queue>#include <map>#include <string>using namespace std;#define FOR(i,a,b) for (int i=(a);i<(b);i++)#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)#define REP(i,n) for (int i=0;i<(n);i++)#define RREP(i,n) for (int i=(n)-1;i>=0;i--)#define pb push_back#define ALL(a) (a).begin(),(a).end()#define EPS (1e-10)#define EQ(a,b) (abs((a)-(b)) < EPS)#define PI 3.1415926535typedef long long ll;typedef pair<int, int> P;//typedef complex<double> C;const ll mod = 1000000007;const int MAX_N = 1000000;int N;// dp[i][j] = i歩目までにj個のケンが連続するようなコースの数(mod 10^9 + 7)ll dp[MAX_N + 1][3];void input() {cin >> N;}void solve() {dp[1][1] = 1;FOR(i, 1, N) {dp[i + 1][0] = (dp[i][1] + dp[i][2]) % mod;dp[i + 1][1] = dp[i][0];dp[i + 1][2] = dp[i][1];}ll sm = (dp[N][0] + dp[N][1] + dp[N][2]) % mod;cout << sm << endl;}int main() {input();solve();}