1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| #include<bits/stdc++.h> using namespace std;
typedef long long ll; const int M=131072*2*2+5,D=(1<<15),MOD=1000003; const double PI=acos(-1.0);
struct Complex{ double x,y; Complex(double _x=0,double _y=0){ x=_x; y=_y; } Complex operator + (Complex a){ return Complex(x+a.x,y+a.y); } Complex operator - (Complex a){ return Complex(x-a.x,y-a.y); } Complex operator * (Complex a){ return Complex(x*a.x-y*a.y,y*a.x+x*a.y); } };
Complex rot[M];
void FFT(Complex *w,int n,int op){ static int r[M]; for(int i=0;i<n;i++) r[i]=(r[i>>1]>>1)|((i&1)?n>>1:0); for(int i=0;i<n;i++) if(i<r[i])swap(w[i],w[r[i]]); for(int len=2;len<=n;len<<=1){ int sub=len>>1; for(int l=0;l<n;l+=len){ for(int i=l;i<l+sub;i++){ Complex &r=rot[sub+i-l]; Complex x=w[i]; Complex y=(Complex){r.x,op*r.y}*w[i+sub]; w[i]=x+y; w[i+sub]=x-y; } } } }
void MTT(int f[],int g[],int len,int ans[]){ static Complex a[M],b[M],c[M],d[M];
memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); memset(d,0,sizeof(d));
for(int i=0;i<len;i++){ a[i].x=f[i]/D; b[i].x=f[i]%D; c[i].x=g[i]/D; d[i].x=g[i]%D; } for(int i=1;i<len;i<<=1) for(int j=0;j<i;j++) rot[i+j]=Complex(cos(PI*j/i),sin(PI*j/i));
FFT(a,len,1); FFT(b,len,1); FFT(c,len,1); FFT(d,len,1);
for(int i=0;i<len;i++){ Complex _a=a[i], _b=b[i], _c=c[i], _d=d[i]; a[i]=_a*_c; b[i]=_a*_d+_b*_c; c[i]=_b*_d; }
FFT(a,len,-1); FFT(b,len,-1); FFT(c,len,-1);
for(int i=0;i<len;i++){ ll w=0; w += (ll)round(a[i].x/len)%MOD*D%MOD*D%MOD; w += (ll)round(b[i].x/len)%MOD*D%MOD; w += (ll)round(c[i].x/len)%MOD; ans[i]=w%MOD; } }
ll QPow(ll bas,int t){ ll ret=1; bas%=MOD; for(;t;bas=bas*bas%MOD,t>>=1) if(t&1)ret=ret*bas%MOD; return ret; }
ll fac[M],fac_i[M];
void Init(){ fac[0]=1; for(int i=1;i<M;i++) fac[i]=fac[i-1]*i%MOD; fac_i[M-1]=QPow(fac[M-1],MOD-2); for(int i=M-1;i>0;i--) fac_i[i-1]=fac_i[i]*i%MOD; }
int n,b,c,d; int a[M];
int main(){ ios::sync_with_stdio(0);
Init(); cin>>n>>b>>c>>d; for(int i=0;i<n;i++) cin>>a[i]; int len=1; for(;len<=(n<<1);len<<=1);
static int f[M],g[M],h[M]; for(int i=0;i<=n;i++){ f[i]=a[i]*fac[i]%MOD; g[i]=QPow(d,n-i)*fac_i[n-i]%MOD; } MTT(f,g,len,h);
memset(f,0,sizeof(f)); memset(g,0,sizeof(g)); for(int i=0;i<=n;i++) f[i]=QPow(b,i)*QPow(c,1LL*i*i%(MOD-1))%MOD*h[n+i]%MOD*fac_i[i]%MOD; int c_i=QPow(c,MOD-2); for(int i=0;i<=2*n;i++) g[i]=QPow(c_i,1LL*(i-n)*(i-n)%(MOD-1)); for(;len<=(2*n<<1);len<<=1); memset(h,0,sizeof(h)); MTT(f,g,len,h); for(int i=0;i<n;i++){ int ans=QPow(c,1LL*i*i%(MOD-1))*h[i+n]%MOD; cout<<(ans+MOD)%MOD<<endl; }
return 0; }
|