版本比较
poly publish
正文
增加 19 行删除 7 行
116 行未改动全部展开11711811912012112212312412512695 行未改动2222232242252242262272282292302312322332343 行未改动2382392402412382422432442452462472482492503 行未改动2542552562572522582592602612622632642652665 行未改动27227327427527627727827928035 行未改动3163173183193203213223233243253263273283292 行未改动33233333433533633733833934021 行未改动3623633643653663673683693702 行未改动373374375376377378379380381382383384370371385373386387388389377116 行未改动全部展开 void clear() { n = l = 0; lim = 1; memset(a,0,sizeof a); memset(b,0,sizeof b); } void FWT_or(LL A[],int type) { for(int mid = 1; mid < lim; mid <<= 1)95 行未改动 { static fwt_base fwt; fwt.clear(); fwt.n = a.n + 1; fwt.lim = fwt.n * 2; fwt.lim = 1; while(fwt.lim < fwt.n) fwt.lim <<= 1; for(int i = 0; i < fwt.n; i ++) fwt.a[i] = a.a[i]; for(int i = 0; i < fwt.n; i ++) fwt.b[i] = b.a[i]; for(int i = fwt.n; i < fwt.lim; i ++) fwt.a[i] = fwt.b[i] = 0; fwt.FWT_or(fwt.a,1),fwt.FWT_or(fwt.b,1); for(int i = 0; i < fwt.lim; i ++) fwt.a[i] = fwt.a[i] * fwt.b[i] % mod; fwt.FWT_or(fwt.a,-1); c.n = fwt.n - 1;3 行未改动 { static fwt_base fwt; fwt.clear(); fwt.n = a.n + 1; fwt.lim = fwt.n * 2; fwt.lim = 1; while(fwt.lim < fwt.n) fwt.lim <<= 1; for(int i = 0; i < fwt.n; i ++) fwt.a[i] = a.a[i]; for(int i = 0; i < fwt.n; i ++) fwt.b[i] = b.a[i]; for(int i = fwt.n; i < fwt.lim; i ++) fwt.a[i] = fwt.b[i] = 0; fwt.FWT_and(fwt.a,1),fwt.FWT_and(fwt.b,1); for(int i = 0; i < fwt.lim; i ++) fwt.a[i] = fwt.a[i] * fwt.b[i] % mod; fwt.FWT_and(fwt.a,-1); c.n = fwt.n - 1;3 行未改动 { static fwt_base fwt; fwt.clear(); fwt.n = a.n + 1; fwt.lim = fwt.n * 2; fwt.lim = 1; while(fwt.lim < fwt.n) fwt.lim <<= 1; for(int i = 0; i < fwt.n; i ++) fwt.a[i] = a.a[i]; for(int i = 0; i < fwt.n; i ++) fwt.b[i] = b.a[i]; for(int i = fwt.n; i < fwt.lim; i ++) fwt.a[i] = fwt.b[i] = 0; fwt.FWT_xor(fwt.a,1),fwt.FWT_xor(fwt.b,1); for(int i = 0; i < fwt.lim; i ++) fwt.a[i] = fwt.a[i] * fwt.b[i] % mod; fwt.FWT_xor(fwt.a,half); c.n = fwt.n - 1;5 行未改动 ntt.clear(); if(n == 1) { b.a[0] = qmi(a.a[0],mod - 2); b.n = 0; return; } inv(a,n + 1 >> 1,b); ntt.n = n,ntt.m = n;35 行未改动 { b.a[0] = 1; LL res = quad_residue::get(a.a[0],mod); b.a[0] = min(res,mod - res); b.n = 0; return; } sqrt(a,n + 1 >> 1,b); for(int i = (n + 1 >> 1); i < n; i ++) b.a[i] = 0; b.n = n - 1; tmp.n = tmp2.n = n; for(int i = 0; i < n; i ++) tmp.a[i] = b.a[i] * 2 % mod; inv(tmp,n,tmp2); b.n = n;2 行未改动 b.n = n; for(int i = 0; i < n; i ++) b.a[i] = (b.a[i] + a.a[i]) % mod; mul(b,tmp2,tmp3); for(int i = 0; i < n; i ++) b.a[i] = tmp3.a[i]; b.n = n - 1; } friend void diff(const poly &a,poly &b) { b.n = a.n - 1;21 行未改动 static poly tmp,tmp2; if(n == 1) { b.a[0] = 1; b.n = 0; return; } exp(a,n + 1 >> 1,b); tmp.n = tmp2.n = n;2 行未改动 tmp2 = a - tmp; tmp.n = tmp2.n = n; mul(tmp2,b,tmp); for(int i = 0; i < n; i ++) b.a[i] = tmp.a[i]; b.n = n - 1; } friend void qmi(const poly &a,const LL &k,poly &b) { static poly tmp; tmp.clear(); ln(a,a.n + 1,tmp); for(int i = 0; i <= tmp.n; i ++) tmp.a[i] = tmp.a[i] * k % mod; int cnt = 1; while(cnt <= tmp.n) cnt <<= 1; b.n = a.n; exp(tmp,cnt,b); exp(tmp,a.n + 1,b); } };}```