![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
FFT&&NTT&&FWT
gjghfd
这个作者很懒,什么都没留下…
展开
-
bzoj3527 -- FFT
代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 800010 8 #define PI acos(-1.0) 9 struct E{ 10 double r,i; 11 E(){} 12 E(double r,do原创 2017-05-26 16:44:20 · 224 阅读 · 0 评论 -
bzoj4259 -- FFT
FFT原创 2017-07-13 17:00:29 · 438 阅读 · 0 评论 -
[ FWT ] Codeforces663E Binary Table
对每一列状压。 令 aia_i 表示状态 ii 的出现次数, bib_i 表示状态 ii 的最小代价。 然后考虑行操作。假设行操作的状态为 SS ,那么答案就是 ∑i=02nai×bi⊕S\sum_{i=0}^{2^n}a_i\times b_{i \oplus S} 直接FWT就好了。#include<bits/stdc++.h> using namespace std; #define原创 2017-10-17 13:45:26 · 257 阅读 · 0 评论 -
[ FFT ] [ HNOI2017 ] BZOJ4827
先断环为链。 假设将 aa 数组右移 xx 位并加 yy ,那么答案就是 ∑(ai+x+y−bi)\sum (a_{i+x}+y-b_i) 化简后发现 yy 可以枚举求最小值。然后就是求 ∑ai+xbi\sum a_{i+x}b_i 的最大值。将 bb 数组取反再FFT即可。 #include using namespace std; typedef long long ll; typ原创 2018-01-22 13:26:18 · 212 阅读 · 0 评论 -
[ DP NTT ] [ SDOI2015 ] BZOJ3992
令 fi,jf_{i,j} 表示前 ii 个数乘积为 jj 的方案数。然后可以写出DP方程。 由于 mm 是质数,可以用原根使乘法转换为加法,然后用快速幂+NTT加速即可。 #include using namespace std; const int N=16400; const int P=1004535809; const int G=3; int k,n,m,p,M; int in原创 2018-01-22 14:56:45 · 172 阅读 · 0 评论 -
[ NTT 多项式求逆 ] BZOJ3456
题解 #include using namespace std; const int N=520010; const int P=1004535809; int k,n,m; int c[N],g[N],G[N]; int d[N],r[N]; int M,l; int inv[N],s[N]; inline int Get(int n){ int Ans=1; for(in原创 2018-01-22 16:37:17 · 221 阅读 · 0 评论 -
[ 斯特林数 NTT ] [ Tjoi2016&Heoi2016 ] BZOJ4555 求和
题解 #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int N=400010; const int P=998244353; int a[N],b...原创 2018-03-09 15:33:18 · 190 阅读 · 0 评论 -
[ DP FWT 链分治 ] [ SDOI2017 ] BZOJ4911 切树游戏
题解 #include<bits/stdc++.h> using namespace std; char nc() { static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; }...原创 2018-05-17 10:20:51 · 493 阅读 · 0 评论 -
[ 分治FFT ] HDU5730
分治FFT裸题 #include<bits/stdc++.h> using namespace std; typedef double db; const int P=313; const int N=100010; const db Pi=acos(-1); struct E { db a,b; E(db a=0,db b=0):a(a),b(b){} ...原创 2018-05-11 17:31:38 · 338 阅读 · 0 评论