-
Notifications
You must be signed in to change notification settings - Fork 0
/
12849.cpp
42 lines (37 loc) · 1.12 KB
/
12849.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#define ll long long
using namespace std;
const int MOD = 1000000007;
ll ans[8][8] = {{0, 1, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 0, 0},
{1, 0, 0, 1, 1, 0, 0, 0}, {0, 1, 1, 0, 1, 1, 0, 0},
{0, 0, 1, 1, 0, 1, 1, 0}, {0, 0, 0, 1, 1, 0, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 1, 0}};
ll arr[8][8] = {{0, 1, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 0, 0},
{1, 0, 0, 1, 1, 0, 0, 0}, {0, 1, 1, 0, 1, 1, 0, 0},
{0, 0, 1, 1, 0, 1, 1, 0}, {0, 0, 0, 1, 1, 0, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 1, 0}};
void solve() {
ll tmp[8][8] = {
0,
};
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 8; k++) {
tmp[i][j] += (ans[i][k] * arr[k][j]);
}
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
ans[i][j] = tmp[i][j] % MOD;
}
}
}
int main() {
int d;
cin >> d;
for (int i = 1; i < d; i++) {
solve();
}
cout << ans[7][7] << "\n";
}