結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2017-10-16 17:28:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 571 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 81,332 KB |
実行使用メモリ | 26,788 KB |
最終ジャッジ日時 | 2024-11-17 20:54:45 |
合計ジャッジ時間 | 1,393 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <queue> #include <vector> #include <cmath> #include <algorithm> #include <map> #include <numeric> using namespace std; using ll = long long; const ll INF = 1e9; const ll MOD = 1e9 + 7; ll dp[1000010][3]; int main() { int N; cin >> N; dp[0][0] = 1; for (int i = 0; i < N; i++) { dp[i+1][0] = (dp[i][1] + dp[i][2]) % MOD; // パー dp[i+1][1] = dp[i][0] % MOD; // ケン dp[i+1][2] = dp[i][1] % MOD; // ケン2回目 } cout << (dp[N][0] + dp[N][1] + dp[N][2]) % MOD << endl; return 0; }