Skip to content

Instantly share code, notes, and snippets.

@ArthurLoboLobo
Last active May 9, 2023 16:49
Show Gist options
  • Save ArthurLoboLobo/5ef99eed544adab1e1fa0f599c3282f9 to your computer and use it in GitHub Desktop.
Save ArthurLoboLobo/5ef99eed544adab1e1fa0f599c3282f9 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4+10;
const int mod = 1e9+7;
int n;
long long dp[maxn];
int main() {
cin >> n;
dp[0] = 1;
dp[1] = 1;
dp[2] = 5;
for(int i = 3; i <= n; i++) {
dp[i] = (1*dp[i-1]+4*dp[i-2]+2*dp[i-3])%mod;
}
cout << dp[n] << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment