HDU-5885 XM Reserves (FFT)


HDU-5885 (FFT)

可以看到题目是一个二维的作差转移,同理的,我们可以将二维转移转化为序列\((x,y)\rightarrow x\cdot m+y\),但是要注意转移边界的问题,建议在每一行多加一些,即\((x,y)\rightarrow x\cdot 3m+y+m\)

如果你还不会作差卷积的构造: BZOJ-3527

处理完转移之后用\(FFT\)即可

#include
using namespace std;

//#define double long double

#define reg register
typedef long long ll;
#define rep(i,a,b) for(reg int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(reg int i=a,i##end=b;i>=i##end;--i)

template  inline void cmin(T &a,T b){ ((a>b)&&(a=b)); } 
template  inline void cmax(T &a,T b){ ((a>1]>>1)|((i&1)<<(c-1));
		FFT(R,a,1),FFT(R,b,1);
		rep(i,0,R) a[i]=a[i]*b[i];
		FFT(R,a,-1);
		double ans=0;
		rep(i,0,R) {
			int x=(i-3*n*m)/(3*m),y=(i-3*n*m)%(3*m)-m;
			if(x>=0 && x=0 && y