結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2020-07-06 08:26:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 1,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 1,675 ms |
コンパイル使用メモリ | 171,440 KB |
実行使用メモリ | 57,868 KB |
最終ジャッジ日時 | 2024-09-24 17:10:01 |
合計ジャッジ時間 | 2,867 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll MOD = 1e9 + 7; int n; cin >> n; vector<vector<ll>> dp(n+1, vector<ll>(3, 0ll)); dp[0][0] = 1ll; for(int i = 1; i <= n; i++){ dp[i][0] += dp[i-1][1] + dp[i-1][2]; dp[i][0] %= MOD; dp[i][1] += dp[i-1][0]; dp[i][1] %= MOD; dp[i][2] += dp[i-1][1]; dp[i][2] %= MOD; } cout << (dp[n][0] + dp[n][1] + dp[n][2]) % MOD << endl; }