矩阵(含乘法与快速幂):
struct matrix{
int h,w;
vector<vector<long long>> a;
matrix(int Int1,int Int2):h(Int1),w(Int2),a(Int1+1,vector<long long>(Int2+1)){}
matrix operator*(const matrix& x) const{
matrix b(h,x.w);
for(int i=1;i<=h;++i){
for(int j=1;j<=x.w;++j){
for(int k=1;k<=w;++k){
b.a[i][j]+=a[i][k]*x.a[k][j];
b.a[i][j]%=MOD;
}
}
}
return b;
}
matrix operator^(const long long& x) const{
if(x==0){
matrix b(h,w);
for(int i=1;i<=h;++i){
b.a[i][i]=1;
}
return b;
}
if(x==1) return *this;
matrix b=*this^(x>>1);
b=b*b;
if(x&1) b=b**this;
return b;
}
};