結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-08-19 01:32:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 1,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 925 ms |
コンパイル使用メモリ | 76,924 KB |
実行使用メモリ | 26,752 KB |
最終ジャッジ日時 | 2024-11-07 19:38:57 |
合計ジャッジ時間 | 2,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <fstream>#include <vector>#include <cstring>#include <string>#include <algorithm>#include <iomanip>using namespace std;typedef long long ll;const ll MOD = ll(1e9 + 7);ll dp[1000010][3];int main() {cin.tie(0);ios::sync_with_stdio(false);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];dp[i + 1][1] += dp[i][0];dp[i + 1][2] += dp[i][1];for(int j = 0; j < 3; j++) {dp[i + 1][j] %= MOD;}}ll ans = (dp[N][0] + dp[N][1] + dp[N][2]) % MOD;cout << ans << endl;}