結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2017-11-29 23:59:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 688 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 65,760 KB |
実行使用メモリ | 26,740 KB |
最終ジャッジ日時 | 2024-11-27 19:18:37 |
合計ジャッジ時間 | 1,311 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <vector> #include <queue> #include <utility> using namespace std; typedef pair<int, int> P; typedef long long ll; #define For(i, a, b) for(int i = (a); i < (b); i++) #define Rep(i, n) For(i, 0, (n)) const int inf = 999999999; const int mod = 1000000007; ll dp[1000010][3]; int main(){ int n; cin >> n; dp[1][0] = 0; dp[1][1] = 1; dp[1][2] = 0; For(i, 2, n + 1){ dp[i][0] = dp[i - 1][1] + dp[i - 1][2]; dp[i][1] = dp[i - 1][0]; dp[i][2] = dp[i - 1][1]; Rep(j, 3){ dp[i][j] %= mod; } } int ans = 0; Rep(i, 3){ ans += dp[n][i]; ans %= mod; } cout << ans << endl; return 0; }