結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2017-02-13 17:39:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 1,305 ms |
コンパイル使用メモリ | 157,544 KB |
実行使用メモリ | 18,932 KB |
最終ジャッジ日時 | 2024-12-29 18:49:57 |
合計ジャッジ時間 | 2,412 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<int> VI;typedef vector<VI> VVI;typedef vector<ll> VL;typedef vector<VL> VVL;typedef pair<int, int> PII;#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)#define REP(i, n) FOR(i, 0, n)#define ALL(x) x.begin(), x.end()#define MOD 1000000007#define INF 1000000000#define PI 3.14159265359#define EPS 1e-12int dp[1000010][4];int main(void){int n;cin >> n;dp[1][1] = 1;FOR(i, 2, n+1) {dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % MOD;dp[i][1] = dp[i-1][0];dp[i][2] = dp[i-1][1];}int ans = 0;REP(i, 3) ans = (ans + dp[n][i]) % MOD;cout << ans << endl;return 0;}