結果
問題 | No.314 ケンケンパ |
ユーザー |
|
提出日時 | 2021-08-31 09:03:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 1,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 857 ms |
コンパイル使用メモリ | 98,544 KB |
実行使用メモリ | 57,980 KB |
最終ジャッジ日時 | 2024-11-25 01:20:40 |
合計ジャッジ時間 | 2,114 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <utility>#include <vector>#include <string>#include <cmath>#include <algorithm>#include <functional>#include <iomanip>#include <map>#include <set>#include <queue>using namespace std;using ll = long long int;#define chmax(x,y) x = (x > (y)) ? x : (x = (y));#define chmin(x,y) x = (x < (y)) ? x : (x = (y));int main(int argc, char const *argv[]){int N; cin >> N;constexpr int Mod = 1e9 + 7;vector<vector<ll>> dp(N+1,vector<ll>(3));dp[0][0] = 1;for(int i=0;i<N;++i){(dp[i+1][2] += dp[i][0]%Mod) %= Mod;(dp[i+1][1] += dp[i][0]%Mod) %= Mod;(dp[i+1][2] += dp[i][1]%Mod) %= Mod;(dp[i+1][0] += dp[i][2]%Mod) %= Mod;}ll answer = dp[N-1][0]%Mod + dp[N-1][1]%Mod + dp[N-1][2]%Mod;answer %= Mod;std::cout << answer << std::endl;}