版本比较
矩阵乘法学习笔记
正文
增加 13 行删除 13 行
58 行未改动5960616263636465666781 行未改动14915015115215315315415515615732 行未改动19019119219319419419519619719825 行未改动22422522622722822822923023023123223323411 行未改动24624724824925025025125225325458 行未改动31331431531631731731831931932032132232316 行未改动34034134234334434434534634734843 行未改动392393394395396396397398398399400401402106 行未改动全部展开50951051151251351351451551551651751851938 行未改动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"; 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; 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 行未改动