当前位置: 首页> 汽车> 车展 > 科技手抄报内容_中国空间站天和核心舱_大连企业黄页电话_百度推广助手下载

科技手抄报内容_中国空间站天和核心舱_大连企业黄页电话_百度推广助手下载

时间:2025/7/11 7:59:39来源:https://blog.csdn.net/m0_59237910/article/details/143638530 浏览次数: 0次
科技手抄报内容_中国空间站天和核心舱_大连企业黄页电话_百度推广助手下载

题目:

题解:

const int MOD = 1000000007;struct Matrix {long mat[6][6];int row, col;
};struct Matrix multiply(struct Matrix a, struct Matrix b) {int rows = a.row, columns = b.col, temp = b.row;struct Matrix c;memset(c.mat, 0, sizeof(c.mat));c.row = rows, c.col = columns;for (int i = 0; i < rows; i++) {for (int j = 0; j < columns; j++) {for (int k = 0; k < temp; k++) {c.mat[i][j] += a.mat[i][k] * b.mat[k][j];c.mat[i][j] %= MOD;}}}return c;
}struct Matrix matricPow(struct Matrix mat, int n) {struct Matrix ret = {{{1, 0, 0, 0, 0, 0}}, 1, 6};while (n > 0) {if ((n & 1) == 1) {ret = multiply(ret, mat);}n >>= 1;mat = multiply(mat, mat);}return ret;
}int checkRecord(int n) {struct Matrix mat = {{{1, 1, 0, 1, 0, 0}, {1, 0, 1, 1, 0, 0}, {1, 0, 0, 1, 0, 0}, {0, 0, 0, 1, 1, 0}, {0, 0, 0, 1, 0, 1}, {0, 0, 0, 1, 0, 0}}, 6, 6};struct Matrix res = matricPow(mat, n);long sum = 0;for (int i = 0; i < res.col; i++) {sum += res.mat[0][i];}return (int)(sum % MOD);
}
关键字:科技手抄报内容_中国空间站天和核心舱_大连企业黄页电话_百度推广助手下载

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: