版本比较
矩阵乘法学习笔记
正文
增加 13 行删除 13 行
58 行未改动59606162636465666781 行未改动14915015115215315415515615732 行未改动19019119219319419519619719825 行未改动22422522622722822923023123223323411 行未改动24624724824925025125225325458 行未改动31331431531631731831932032132232316 行未改动34034134234334434534634734843 行未改动392393394395396397398399400401402106 行未改动全部展开50951051151251351451551651751851938 行未改动58 行未改动ll k;struct matrix {ll a[maxn][maxn];matrix operator* (const matrix &tmp) const {matrix res;for(int i = 1; i <= n; i++) {for(int j = 1; j <= n; j++) {81 行未改动ll n;struct matrix {int a, b; ll s[5][5];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= a; i++) {32 行未改动while(T--) {cin >> n;if(n <= 3) { cout << "1\n"; continue; }matrix ans = st * quick_pow(base, n - 3);cout << ans.s[1][1] << "\n";}return 0;}25 行未改动ll mod, a, c, X0, n, g;struct matrix {int a, b;ll s[5][5];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {11 行未改动matrix res = {2, 2, {{}, {0, 1, 0}, {0, 0, 1}}};while(b) {if(b & 1) res = res * a;a = a * a;b >>= 1;}return res;}58 行未改动char s[maxn];struct matrix {int a, b;ll mtx[30][30];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {16 行未改动while(b) {if(b & 1) res = res * a;a = a * a;b >>= 1;}return res;}int main() {43 行未改动ll n;struct matrix {int a, b;ll mtx[8][8];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {106 行未改动全部展开int X[maxm << 1];struct matrix {int mtx[maxm << 1][maxm << 1];matrix() { memset(mtx, 0x3f, sizeof(mtx)); }matrix operator* (const matrix &tmp) const {matrix res;for(int i = 1; i <= len; i++)for(int j = 1; j <= len; j++)38 行未改动58 行未改动59606162636465666781 行未改动14915015115215315415515615732 行未改动19019119219319419519619719825 行未改动22422522622722822923023123223323411 行未改动24624724824925025125225325458 行未改动31331431531631731831932032132232316 行未改动34034134234334434534634734843 行未改动392393394395396397398399400401402106 行未改动全部展开50951051151251351451551651751851938 行未改动58 行未改动ll k;struct matrix {ll a[maxn][maxn];matrix operator* (const matrix &tmp) const {matrix res;for(int i = 1; i <= n; i++) {for(int j = 1; j <= n; j++) {81 行未改动ll n;struct matrix {int a, b; ll s[5][5];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= a; i++) {32 行未改动while(T--) {cin >> n;if(n <= 3) { cout << "1\n"; continue; }matrix ans = st * quick_pow(base, n - 3);cout << ans.s[1][1] << "\n";}return 0;}25 行未改动ll mod, a, c, X0, n, g;struct matrix {int a, b;ll s[5][5];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {11 行未改动matrix res = {2, 2, {{}, {0, 1, 0}, {0, 0, 1}}};while(b) {if(b & 1) res = res * a;a = a * a;b >>= 1;}return res;}58 行未改动char s[maxn];struct matrix {int a, b;ll mtx[30][30];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {16 行未改动while(b) {if(b & 1) res = res * a;a = a * a;b >>= 1;}return res;}int main() {43 行未改动ll n;struct matrix {int a, b;ll mtx[8][8];matrix operator* (const matrix &tmp) const {matrix res;res.a = a, res.b = tmp.b;for(int i = 1; i <= res.a; i++) {106 行未改动全部展开int X[maxm << 1];struct matrix {int mtx[maxm << 1][maxm << 1];matrix() { memset(mtx, 0x3f, sizeof(mtx)); }matrix operator* (const matrix &tmp) const {matrix res;for(int i = 1; i <= len; i++)for(int j = 1; j <= len; j++)38 行未改动