-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12850.cpp
More file actions
49 lines (48 loc) · 1017 Bytes
/
12850.cpp
File metadata and controls
49 lines (48 loc) · 1017 Bytes
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
43
44
45
46
47
48
49
#include<iostream>
#include<vector>
#define mod 1000000007
using namespace std;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
long long d[100001][9];
vvll p = {
{0, 1, 1, 0, 0, 0, 0, 0},
{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, 1},
{0, 0, 0, 1, 1, 0, 1, 0},
{0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 1, 0, 1, 0}
};
vvll multi(vvll &a , vvll &b){
vvll ret;
for(int i=0;i<8;i++){
vll r;
for(int j=0;j<8;j++){
ll tmp=0;
for(int k=0;k<8;k++){
tmp+=(a[i][k]*b[k][j]);
tmp%=mod;
}
r.push_back(tmp);
}
ret.push_back(r);
}
return ret;
}
int main(){
vvll ans=p;
int n;
cin>>n;
n--;
while(n>0){
if(n%2==1){
ans = multi(ans,p);
}
p = multi(p,p);
n/=2;
}
cout<<ans[0][0];
}