2019 Shanghai Online Contest Problem C Triple

做三遍fft

算法没问题被卡常了

#include
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const int N=3e5+10;
inline void read(int &x){char ch;bool ok;
for(ok=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') ok=1;
for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok) x=-x;}
struct Complex{
    double x,y;
    Complex(double _x = 0.0,double _y = 0.0){
        x = _x;
        y = _y;
    }
    Complex operator -(const Complex &b)const{
        return Complex(x-b.x,y-b.y);
    }
    Complex operator +(const Complex &b)const{
        return Complex(x+b.x,y+b.y);
    }
    Complex operator *(const Complex &b)const{
        return Complex(x*b.x-y*b.y,x*b.y+y*b.x);
    }
};
/*
* 进行FFT和IFFT前的反转变换。
* 位置i和 (i二进制反转后位置)互换
* len必须去2的幂
*/
void change(Complex y[],int len)
{
    int i,j,k;
    for(i = 1, j = len/2; i = k)
        {
            j -= k;
            k /= 2;
        }
        if(j < k)j += k;
    }
}
/*
* 做FFT
* len必须为2^k形式,
* on==1时是DFT, on==-1时是IDFT
*/
void fft(Complex y[],int len,int on)
{
    change(y,len);
    for(int h = 2; h <= len; h <<= 1)
    {
        Complex wn(cos(-on*2*PI/h),sin(-on*2*PI/h));
        for(int j = 0; j < len; j+=h)
        {
            Complex w(1,0);
            for(int k = j; k < j+h/2; k++)
            {
                Complex u = y[k];
                Complex t = w*y[k+h/2];
                y[k] = u+t;
                y[k+h/2] = u-t;
                w = w*wn;
            }
        }
    }
    if(on == -1)
        for(int i = 0; i < len; i++)
            y[i].x /= len;
}
Complex AA[N],BB[N];
int A[N],B[N],C[N],D[N],len;
ll AnsMax,AnsMin;
int ma;
void Solve(int A[],int B[],int C[],int n){
    ll Sum=1ll*n*n;
    for(int i=0;i>T;for(int flag=1;flag<=T;++flag){
        int n;cin>>n;
        ma=0;
        for(int i=1;i<=n;++i)read(A[i]),ma=max(A[i],ma);
        for(int i=1;i<=n;++i)read(B[i]),ma=max(B[i],ma);
        for(int i=1;i<=n;++i)read(C[i]),ma=max(C[i],ma);
        len=1;while(len

 

你可能感兴趣的:(2019 Shanghai Online Contest Problem C Triple)