The main idea: given n points, the Coulomb force between the point I and the J points is (QI*QJ)/(I-J) ^2, the left side is defined as the positive direction, and the ratio of the resultant force to the charge amount of each point is obtained.
See http://eolv.farbox.com/post/shui-yu-zheng-feng/2014-12-07 I'm too lazy to call--
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include < algorithm> #define M 263000#define PI 3.1415926535897932384626433832795028841971using namespace Std;struct complex{ Long double A, b; Complex () {}complex (long double _,long double __): A (_), B (__) {}complex operator + (const Complex &x) Const{return Comp Lex (a+x.a,b+x.b);} Complex operator-(const Complex &x) Const{return Complex (a-x.a,b-x.b);} Complex operator * (const Complex &x) Const{return Complex (A*X.A-B*X.B,A*X.B+B*X.A);} void operator *= (const Complex &x) {*this= (*this) *x;}} A[m],b[m],c[m];int N;long Double q[m],ans[m];void FFT (Complex x[],int n,int type) {static Complex temp[m];if (n==1) return ; int i;for (i=0;i<n;i+=2) temp[i>>1]=x[i],temp[i+n>>1]=x[i+1];memcpy (x,temp,sizeof (Complex) *n); Complex *l=x,*r=x+ (n>>1); FFT (L,n>>1,type); FFT (R,n>>1,type); Complex Root (cos (type*2*pi/n), sin (type*2*pi/n)), W (1,0); for (i=0;i<n>>1;i++,w*=root) temp[i]=l[i]+w*r[i],temp[i+ (n>>1)]=l[i]-w*r[i];memcpy (x,temp,sizeof (Complex) *n);} int main () {int i,digit;double x;cin>>n;for (digit=1;digit<=n<<1;digit<<=1); for (i=0;i<n;i++ ) scanf ("%lf", &x), Q[i]=x;for (i=1;i<n;i++) b[i].a=1.0/i/i; FFT (b,digit,1); for (i=0;i<n;i++) A[i]=complex (q[i],0); FFT (a,digit,1); for (i=0;i<digit;i++) c[i]=a[i]*b[i]; FFT (C,digit,-1), for (i=0;i<n;i++) ans[i]+=c[i].a;for (i=0;i<n;i++) A[i]=complex (q[n-i-1],0), for (i=n;i< digit;i++) A[i]=complex (0,0); FFT (a,digit,1); for (i=0;i<digit;i++) c[i]=a[i]*b[i]; FFT (C,digit,-1), for (i=0;i<n;i++) ans[i]-=c[n-i-1].a;for (i=0;i<n;i++) printf ("%lf\n", (double) ans[i]/digit) ;//cout<<ans[i]/digit<<endl;return 0;}
Bzoj 3257 ZJOI2014 Force Fast Fourier transform