CI mod = 1e9 + 7;
struct matrix{ int a[maxm][maxm], n, m;};
matrix matrixMul(matrix p, matrix q){
matrix res;
res.n = p.n, res.m = q.m;
f (i, 0, res.n - 1)
f (j, 0, res.m - 1){
res.a[i][j] = 0;
f (k, 0, p.m - 1)
(res.a[i][j] += p.a[i][k] * q.a[k][j] % mod) %= mod;
}
return res;
}
matrix ksm(matrix a, int b){
matrix ans = I;
for (; b; b >>= 1, a = matrixMul(a, a))
if (b & 1)
ans = matrixMul(ans, a);
return ans;
}
标签:return,matrix,res,矩阵,matrixMul,ans,mod,模板,乘法
From: https://www.cnblogs.com/yh2021shx/p/17477287.html