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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#include<bits/stdc++.h>
#define ll long long
#define FIO "loj150"
using namespace std;
const int N=1e5+5,MOD=998244353,P=19,INV2=MOD+1>>1;
inline int add(int a,const int &b){if((a+=b)>=MOD)a-=MOD;return a;}
inline int sub(int a,const int &b){if((a-=b)< 0)a+=MOD;return a;}
inline int mul(const int &a,const int &b){return 1ll*a*b%MOD;}
inline void inc(int &a,const int &b=1){a=add(a,b);}
inline void dec(int &a,const int &b=1){a=sub(a,b);}
inline void pro(int &a,const int &b){a=mul(a,b);}
inline int qpow(int a,int b){int c=1;for(;b;b>>=1,pro(a,a))if(b&1)pro(c,a);return c;}
int n,k,w[2][1<<P];
inline void pre(){
for(int i=1;i<1<<P;i<<=1){
w[0][i]=w[1][i]=1;
int wn1=qpow(3,(MOD-1)/(i<<1)),wn0=qpow(wn1,MOD-2);
for(int j=1;j<i;j++)
w[0][i+j]=mul(w[0][i+j-1],wn0),w[1][i+j]=mul(w[1][i+j-1],wn1);
}
}
#define poly vector<int>
inline void read(poly &a,const int &n){
a.resize(n);
for(int i=0;i<n;i++)scanf("%d",&a[i]);
}
inline void out(const poly &a){
for(int i=0,n=a.size();i<n;i++)printf("%d%c",a[i],i^n-1?' ':'\n');
}
inline void clear(poly &a){
int n=a.size();
while(n>1&&!a[n-1])n--;
a.resize(n);
}
inline poly operator +(poly a,const int &b){inc(a[0],b);return a;}
inline poly operator +(const int &b,poly a){inc(a[0],b);return a;}
inline poly operator -(poly a,const int &b){dec(a[0],b);return a;}
inline poly operator -(const int &b,poly a){dec(a[0],b);return a;}
inline poly operator +(poly a,const poly &b){
if(a.size()<b.size())a.resize(b.size());
for(int i=0,n=a.size();i<n;i++)inc(a[i],b[i]);
return a;
}
inline poly operator -(poly a,const poly &b){
if(a.size()<b.size())a.resize(b.size());
for(int i=0,n=a.size();i<n;i++)dec(a[i],b[i]);
return a;
}
inline void ntt(int *f,int opt,int l){
poly rev(l);
for(int i=0;i<l;i++){rev[i]=(rev[i>>1]>>1)|((i&1)*(l>>1));if(i<rev[i])swap(f[i],f[rev[i]]);}
for(int i=1;i<l;i<<=1)
for(int j=0;j<l;j+=i<<1)
for(int k=0;k<i;k++){
int x=f[j+k],y=mul(f[i+j+k],w[opt][i+k]);
f[j+k]=add(x,y);
f[i+j+k]=sub(x,y);
}
if(opt)for(int i=0,inv=qpow(l,MOD-2);i<l;i++)pro(f[i],inv);
}
inline poly operator *(poly a,poly b){
int n=a.size(),m=b.size(),l=1;
while(l<n+m)l<<=1;
a.resize(l);b.resize(l);
ntt(&a[0],0,l);ntt(&b[0],0,l);
for(int i=0;i<l;i++)pro(a[i],b[i]);
ntt(&a[0],1,l);
clear(a);
return a;
}
inline poly& operator *=(poly &a,const poly b){return a=a*b;}
inline poly operator *(poly a,const int &b){
for(int i=0,n=a.size();i<n;i++)pro(a[i],b);
return a;
}
inline poly inv(const poly &a,const int &n){
if(n==1)return poly(1,qpow(a[0],MOD-2));
int l=1;while(l<=n<<1)l<<=1;
poly b=inv(a,n+1>>1),c(l);b.resize(l);
for(int i=0;i<n;i++)c[i]=a[i];
ntt(&b[0],0,l);ntt(&c[0],0,l);
for(int i=0;i<l;i++)pro(b[i],sub(2,mul(b[i],c[i])));
ntt(&b[0],1,l);
b.resize(n);
clear(b);
return b;
}
inline poly inv(const poly &a){return inv(a,a.size());}
int B;
#define pii pair<int,int>
inline pii operator *(pii a,pii b){
return pii(add(mul(a.first,b.first),mul(mul(a.second,b.second),B)),add(mul(a.first,b.second),mul(a.second,b.first)));
}
inline pii qpow(pii a,int b){pii c=pii(1,0);for(;b;b>>=1,a=a*a)if(b&1)c=c*a;return c;}
inline int remain(int x){
if(x<=1)return x;
int a=mul(mul(rand(),rand()),rand());
while(qpow(B=sub(mul(a,a),x),MOD-1>>1)==1)a=mul(mul(rand(),rand()),rand());
pii A=pii(a,1),ans=qpow(A,MOD+1>>1);
return min(ans.first,MOD-ans.first);
}
inline poly sqrt(const poly &a,const int &n){
if(n==1)return poly(1,remain(a[0]));
int l=1;while(l<=n<<1)l<<=1;
poly b=sqrt(a,n+1>>1),c(l),d;
b.resize(n);d=inv(b)*INV2;
b.resize(l);d.resize(l);
for(int i=0;i<n;i++)c[i]=a[i];
ntt(&b[0],0,l);ntt(&c[0],0,l);ntt(&d[0],0,l);
for(int i=0;i<l;i++)b[i]=mul(d[i],add(mul(b[i],b[i]),c[i]));
ntt(&b[0],1,l);
b.resize(n);
clear(b);
return b;
}
inline poly sqrt(const poly &a){return sqrt(a,a.size());}
inline poly deri(poly a){
int n=a.size();
if(n==1)return poly(1,0);
for(int i=0;i<n;i++)a[i]=mul(a[i+1],i+1);
a.resize(n-1);
return a;
}
inline poly inte(poly a){
int n=a.size();
a.resize(n+1);
for(int i=n;i;i--)a[i]=mul(a[i-1],qpow(i,MOD-2));
a[0]=0;
return a;
}
inline poly ln(const poly &a){
int n=a.size();
poly c=inv(a)*deri(a);
c.resize(n-1);
return inte(c);
}
inline poly exp(const poly &a,const int &n){
if(n==1)return poly(1,1);
poly b=exp(a,n+1>>1),c;
b.resize(n);c=ln(b);
for(int i=0;i<n;i++)c[i]=sub(a[i],c[i]);
inc(c[0]);
b*=c;
b.resize(n);
return b;
}
inline poly exp(const poly &a){return exp(a,a.size());}
inline poly qpow(poly a,const double &b){return exp(ln(a)*b);}
poly a;
int main(){
srand(19260817);
pre();
scanf("%d%d",&n,&k);
read(a,1+n);
a=deri(qpow(1+ln(2+a-a[0]-exp(inte(inv(sqrt(a))))),k));
a.resize(n);
out(a);
return 0;
}
|