记录编号 |
452575 |
评测结果 |
AAAAAAAAAA |
题目名称 |
CrazyCooook |
最终得分 |
100 |
用户昵称 |
Cooook |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
12.330 s |
提交时间 |
2017-09-19 20:33:52 |
内存使用 |
208.31 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using std::swap;
typedef long long ll;
const int g = 3,mod = 998244353,MAXN = 1<<22;
int n,rev[MAXN],T,k;
ll a[MAXN],b[MAXN],c[MAXN],f[MAXN],fac[MAXN],ni[MAXN];
template<typename _t>
inline _t read(){
_t x=0,f=1;
char ch=getchar();
for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-')f=-f;
for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+(ch^48);
return x*f;
}
inline ll qpow(ll x,ll k){
register ll Ans = 1;
for(;k;k>>=1,x=x*x%mod) if(k&1) Ans = Ans * x % mod;
return Ans;
}
inline void fnt(ll *f,register int flag) {
for(register int i = 0;i<n;i++) if(i>rev[i]) swap(f[i],f[rev[i]]); ll w,wn,t,u;
for(register int m = 2;m<=n;m<<=1){
wn = qpow(g,flag==1?(mod-1)/m:mod-1-(mod-1)/m),w=1;
for(register int i = 0;i<n;i+=m,w=1) for(register int k = 0;k<(m>>1);k++,w=1ll*w*wn%mod)
u = f[i+k],t = 1ll*f[i+k+(m>>1)]*w%mod,f[i+k] = (u+t)%mod,f[i+k+(m>>1)] = (u-t)%mod;
}
if(flag == -1) {
int inv = qpow(n,mod-2);
for(register int i = 0;i<n;i++) f[i] = 1ll * f[i] * inv % mod;
}
}
inline void NTT(ll *a,ll *b,int len,ll *Ans){
for(n=1;n<(len<<1);n<<=1);
for(register int i = 0;i<n;i++) {
if(i&1) rev[i] = rev[i>>1]>>1|(n>>1);
else rev[i] = rev[i>>1]>>1;
} fnt(a,1); fnt(b,1);
for(register int i = 0;i<n;i++) c[i] =1ll * a[i] * b[i] % mod;fnt(c,-1);
for(register int i = 0;i<n;i++) Ans[i] = (c[i] % mod + mod)%mod;
}
inline void init(){
fac[0] = 1; int N = 200000;
for(register int i = 1;i<=N;i++) fac[i] = fac[i-1] * i % mod; ni[N] = qpow(fac[N],mod-2);
for(register int i = N-1;i>=1;i--) ni[i] = 1ll * ni[i+1] * (i+1) % mod; ni[0] = 1;
for(register int i = 0;i<=N;i++) a[i] = qpow(ni[i],k),b[i] = qpow(ni[i],k);NTT(a,b,N+1,f);
for(register int i = 0;i<=N;i++) f[i] = f[i] * qpow(fac[i],k) % mod;
}
int main(){
freopen("CrazyCooook.in","r",stdin);
freopen("CrazyCooook.out","w",stdout);
T = read<int>();k = read<int>();init();
while(T --) printf("%lld\n",f[read<int>()]);
return 0;
}