# [ZJOI2014]力 题解

Fj=i<jqiqj(ij)2i>jqiqj(ij)2

n行，第i行输出Ei。

Ei=j<iqj(ij)2j>iqj(ij)2=j=1i1qj(ij)2j=i+1nqj(ij)2

gi={1i2(i0)0(i=0)

Ei=j=1i1qjgijj=i+1nqjaji

Ei=φiωt

ωt=i<jnqjgji=i<j+inqj+igj=0<jniqj+igj=0<nijniqnjgnij=0jniqnjgnij=0jtqnjgtj(t=ni)=0jtpjgtj(pi=qni)=P×G

#include <bits/stdc++.h>
using namespace std ;
const int maxn = 400005 ;
const double PI = acos(-1.0) ;
int n, m, dep, rev[maxn], len ;
double q[maxn], g[maxn], p[maxn], ans[maxn] ;
complex <double> a[maxn], b[maxn] ;
void DFT ( complex <double> a[], int len, int t ) {
int i, j, k ;
for ( i = 1 ; i < len ; i ++ ) if ( i<rev[i] ) swap ( a[i], a[rev[i]] ) ;
for ( j = 1 ; j < len ; j <<= 1 ) {
complex <double> dw( cos(2*PI/(j<<1)), sin(2*t*PI/(j<<1)) ) ;
for ( i = 0 ; i < len ; i += (j<<1) ) {
complex <double> w(1,0), t0, t1 ;
for ( k = 0 ; k < j ; k ++, w *= dw ) {
t0 = a[i+k] ;
t1 = w*a[i+k+j] ;
a[i+k] = t0+t1 ;
a[i+j+k] = t0-t1 ;
}
}
}
for ( i = 0 ; i <= len && t == -1 ; i ++ ) a[i] /= len ;
}
void FFT ( double x[], double y[], complex<double> a[], complex<double> b[], complex <double> c[], int len ) {
int i ;
for ( i = 0 ; i < len ; i ++ ) a[i] = x[i] ;
for ( i = 0 ; i < len ; i ++ ) b[i] = y[i] ;
DFT ( a, len, 1 ) ; DFT ( b, len, 1 ) ;
for ( i = 0 ; i < len ; i ++ ) c[i] = a[i]*b[i] ;
DFT ( c, len, -1 ) ;
}
void init() {
int i, j, k = 0 ;
len = n<<1|1 ;
for ( k = 1 ; k <= len ; k <<= 1 ) ++ dep ;
len = k ;
for ( i = 1 ; i < len ; i ++ ) rev[i] = (rev[i>>1]>>1)|((i&1)<<dep-1) ;
}
int main() {
int i, j, k ;
scanf ( "%d", &n ) ;
for ( i = 1 ; i <= n ; i ++ ) scanf ( "%lf", q+i ) ;
for ( p[0] = q[n], i = 1 ; i <= n ; i ++ ) g[i] = 1.0/(i*i), p[i] = q[n-i] ;
init() ;
FFT ( q, g, a, b, a, len ) ;
for ( i = 0 ; i <= n ; i ++ ) ans[i] = a[i].real() ;
FFT ( p, g, a, b, a, len ) ;
for ( i = 0 ; i <= n ; i ++ ) ans[i] -= a[n-i].real() ;
for ( i = 1 ; i <= n ; i ++ ) printf ( "%.3lf\n", ans[i] ) ;
return 0 ;
}