struct Matrix
{
int a[M][M];
Matrix() {}
Matrix(int val)
{
memset(a,0,sizeof a);
for(int i=0;i<=tot;i++)
a[i][i]=val;
}
int* operator [] (int i)
{
return a[i];
}
friend Matrix operator * (Matrix x,Matrix y)
{
Matrix z(0);
for(int i=0;i<=tot;i++)
for(int j=0;j<=tot;j++)
for(int k=0;k<=tot;k++)
(z[i][j]+=(long long)x[i][k]*y[k][j]%MOD)%=MOD;
return z;
}
friend Matrix Quick_Power(Matrix x,int y)
{
Matrix re(1);
while(y)
{
if(y&1) re=re*x;
x=x*x; y>>=1;
}
return re;
}
}
{模板}打包矩阵乘法
最新推荐文章于 2021-01-05 19:53:24 发布