#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const double PI=acos(-1);
const int M=110000;
struct complex{//虚数a+bi
double a,b;complex(){}complex(double x,double y){a=x;b=y;}
complex operator +(complex x)const{return complex (a+x.a,b+x.b);}
complex operator -(complex x)const{return complex (a-x.a,b-x.b);}
complex operator *(complex x)const{return complex (a*x.a-b*x.b,a*x.b+b*x.a);}
}a[M],b[M];
int n;
void fft(complex *a,int f){
for(int i=0,j=0;i<n;i++){
if(i>j) swap(a[i],a[j]);
for(int l=n>>1;(j^=l)<l;l>>=1);
}
for(int i=1;i<n;i<<=1){complex w(cos(PI/i),f*sin(PI/i));
for(int j=0;j<n;j+=(i<<1)){complex e(1,0);
for(int k=0;k<i;k++,e=e*w){
complex x=a[j+k],y=e*a[j+k+i];
a[j+k]=x+y;a[j+k+i]=x-y;
}
}
}
if(f==-1) for(int i=0;i<n;i++) a[i].a/=n;
}
int main(){
scanf("%d",&n);n--;
for(int i=0;i<=n;i++) scanf("%lf",&a[i].a);
for(int i=0;i<n;i++) b[i].a=-1.0/(double)(n-i)/(double)(n-i);
for(int i=n+1;i<=2*n;i++) b[i].a=-b[2*n-i].a;
int m=n*4;
for(n=1;n<=m;n<<=1);
fft(a,1);fft(b,1);
for(int i=0;i<=n;i++) a[i]=a[i]*b[i];
fft(a,-1);
for(int i=m/4;i<=m/2;i++) printf("%.3lf\n",a[i].a);
}
FFT
最新推荐文章于 2021-03-19 19:31:19 发布