1 //矩阵大小上限 2 const int SIZ=100; 3 int MOD=100; 4 5 //矩阵大小为n*m,初始化全部为0 6 struct mat 7 { 8 int n,m; 9 int ar[SIZ][SIZ];10 mat()11 {12 memset(ar,0,sizeof(ar));13 n=m=SIZ;14 };15 };16 17 //矩阵乘法18 mat operator *(mat a,mat b)19 {20 mat c;21 c=mat();22 c.n=a.n;23 c.m=b.m;24 for(int i=1;i<=a.n;i++)25 for(int j=1;j<=b.n;j++)26 if(a.ar[i][j]!=0)27 for(int k=1;k<=a.m;k++)28 {29 c.ar[i][k]+=(a.ar[i][j]*b.ar[j][k])%MOD;30 c.ar[i][k]%=MOD;31 }32 return c;33 }34 35 //矩阵加法36 mat operator +(mat a,mat b)37 {38 mat c;39 c=mat();40 c.n=a.n;41 c.m=a.m;42 for(int i=1;i<=a.n;i++)43 for(int j=1;j