結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2023-03-15 13:39:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 1,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 3,735 ms |
コンパイル使用メモリ | 252,396 KB |
最終ジャッジ日時 | 2025-02-11 11:35:59 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=4444444444444444444; ll mod=1000000007; int main(){ ll n; cin >> n; vector<vector<ll>>dp(n,vector<ll>(3,0)); dp[0][1]=1; for (ll i = 1; i < n; i++) { dp[i][1]+=dp[i-1][0]; dp[i][2]+=dp[i-1][1]; dp[i][0]+=dp[i-1][1]; dp[i][0]+=dp[i-1][2]; dp[i][0]%=mod; } ll ans=0; for (ll i = 0; i < 3; i++) { ans+=dp[n-1][i]; ans%=mod; } cout << ans << endl; }