Skip to content

Commit

Permalink
Add 12849.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jan 6, 2024
1 parent 5d990c8 commit 8e0b669
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 12xxx/12849.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;

void solve(void) {
int d; cin >> d;

vector<vector<long long>> dp(d+1, vector<long long>(8, 0));
dp[0][0] = 1;
for (int i=1; i<=d; i++) {
dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % MOD;
dp[i][1] = (dp[i-1][0] + dp[i-1][2] + dp[i-1][3]) % MOD;
dp[i][2] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][3] + dp[i-1][4]) % MOD;
dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][4] + dp[i-1][5]) % MOD;
dp[i][4] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][5] + dp[i-1][6]) % MOD;
dp[i][5] = (dp[i-1][3] + dp[i-1][4] + dp[i-1][7]) % MOD;
dp[i][6] = (dp[i-1][4] + dp[i-1][7]) % MOD;
dp[i][7] = (dp[i-1][5] + dp[i-1][6]) % MOD;
}

cout << dp[d][0];
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);

solve();
return 0;
}

0 comments on commit 8e0b669

Please sign in to comment.