-
-
Save ArthurLoboLobo/5ef99eed544adab1e1fa0f599c3282f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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