模板
矩阵 矩乘(现在正确, 20191021) const LL MOD = 1e9 + 7; struct Matrix { int row, col; LL val[33][33]; void init0() { memset(val, 0, sizeof val); } void init1() { memset(val, 0, sizeof val); for (int i = 0; i < row; ++ i) val[i][i] = 1; } Matrix () {} Matrix (int _row, int _col) { row = _row; col = _col; memset(val, 0, sizeof val); } Matrix operator * (const Matrix B) const { Matrix C (row, B.col); for (int i = 0; i < row; ++ i) for (int j = 0; j < B.col; ++ j) for (int k = 0; k < col; ++ k) (C.val[i][j] += val[i][k] * B.val[k][j] % MOD) %= MOD/*, printf("%d%d += %lld * %lld\n", i, j, val[i][k], val[k][j