题面
题解
我数学好像学得太差了
据说根据反三角函数求导公式
\[{d\over dx}\arcsin x={1\over \sqrt{1-x^2}}
\]
\]
\[{d\over dx}\arctan x={1\over 1+x^2}
\]
\]
先看\(\arcsin\),可以发现有
\[{d\over dx}F(x)={A'(x)\over \sqrt{1-A^2(x)}}
\]
\]
\[F(x)=\int {A'(x)\over \sqrt{1-A^2(x)}} dx
\]
\]
同理可得\(\arctan\)
\[F(x)=\int {A'(x)\over 1+A^2(x)} dx
\]
\]
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
while(z[++Z]=x%10+48,x/=10);
while(sr[++C]=z[Z],--Z);sr[++C]=' ';
}
const int N=(1<<18)+5,P=998244353,inv2=499122177;
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
R int res=1;
for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
return res;
}
int inv[N],r[21][N],rt[2][N<<1],lg[N],lim,d;
int iinv(R int x){return x<=262144?inv[x]:mul(P-P/x,iinv(P%x));}
void Pre(){
fp(d,1,18){
fp(i,1,(1<<d)-1)r[d][i]=(r[d][i>>1]>>1)|((i&1)<<(d-1));
lg[1<<d]=d;
}
inv[0]=inv[1]=1;
fp(i,2,262144)inv[i]=mul(P-P/i,inv[P%i]);
for(R int t=(P-1)>>1,i=1,x,y;i<=262144;i<<=1,t>>=1){
x=ksm(3,t),y=iinv(x),rt[0][i]=rt[1][i]=1;
fp(k,1,i-1)
rt[1][i+k]=mul(rt[1][i+k-1],x),
rt[0][i+k]=mul(rt[0][i+k-1],y);
}
}
void NTT(int *A,int ty){
fp(i,0,lim-1)if(i<r[d][i])swap(A[i],A[r[d][i]]);
for(R int mid=1;mid<lim;mid<<=1)
for(R int j=0,t;j<lim;j+=(mid<<1))
fp(k,0,mid-1)
A[j+k+mid]=dec(A[j+k],t=mul(rt[ty][mid+k],A[j+k+mid])),
A[j+k]=add(A[j+k],t);
if(!ty)fp(i,0,lim-1)A[i]=mul(A[i],inv[lim]);
}
void Inv(int *a,int *b,int len){
if(len==1)return b[0]=iinv(a[0]),void();
Inv(a,b,len>>1);
static int A[N],B[N];lim=(len<<1),d=lg[lim];
fp(i,0,len-1)A[i]=a[i],B[i]=b[i];
fp(i,len,lim-1)A[i]=B[i]=0;
NTT(A,1),NTT(B,1);
fp(i,0,lim-1)A[i]=mul(A[i],mul(B[i],B[i]));
NTT(A,0);
fp(i,0,len-1)b[i]=dec(add(b[i],b[i]),A[i]);
fp(i,len,lim-1)b[i]=0;
}
void Sqrt(int *a,int *b,int len){
if(len==1)return b[0]=1,void();
Sqrt(a,b,len>>1);
static int A[N],B[N];
fp(i,0,len-1)A[i]=a[i];Inv(b,B,len);
lim=(len<<1),d=lg[lim];
fp(i,len,lim-1)A[i]=B[i]=0;
NTT(A,1),NTT(B,1);
fp(i,0,lim-1)A[i]=mul(A[i],B[i]);
NTT(A,0);
fp(i,0,len-1)b[i]=mul(add(b[i],A[i]),inv2);
fp(i,len,lim-1)b[i]=0;
}
void Arcsin(int *a,int *b,int len){
static int A[N],B[N];
lim=(len<<1),d=lg[lim];
fp(i,0,len-1)A[i]=a[i];fp(i,len,lim-1)A[i]=0;
NTT(A,1);fp(i,0,lim-1)A[i]=mul(A[i],A[i]);
NTT(A,0);fp(i,0,len-1)A[i]=P-A[i];++A[0];
Sqrt(A,B,len),Inv(B,A,len);
lim=(len<<1),d=lg[lim];
fp(i,1,len-1)B[i-1]=mul(a[i],i);B[len-1]=0;
fp(i,len,lim-1)A[i]=B[i]=0;
NTT(A,1),NTT(B,1);
fp(i,0,lim-1)A[i]=mul(A[i],B[i]);
NTT(A,0);
fp(i,1,len-1)b[i]=mul(A[i-1],inv[i]);b[0]=0;
}
void Arctan(int *a,int *b,int len){
static int A[N],B[N];
lim=(len<<1),d=lg[lim];
fp(i,0,len-1)A[i]=a[i];fp(i,len,lim-1)A[i]=0;
NTT(A,1);fp(i,0,lim-1)A[i]=mul(A[i],A[i]);
NTT(A,0);++A[0];
Inv(A,B,len);
lim=(len<<1),d=lg[lim];
fp(i,1,len-1)A[i-1]=mul(a[i],i);A[len-1]=0;
fp(i,len,lim-1)A[i]=B[i]=0;
NTT(A,1),NTT(B,1);
fp(i,0,lim-1)A[i]=mul(A[i],B[i]);
NTT(A,0);
fp(i,1,len-1)b[i]=mul(A[i-1],inv[i]);b[0]=0;
}
int A[N],B[N],n,ty;
int main(){
// freopen("testdata.in","r",stdin);
n=read(),ty=read(),Pre();
fp(i,0,n-1)A[i]=read();
int len=1;while(len<=n)len<<=1;
if(ty)Arctan(A,B,len);else Arcsin(A,B,len);
fp(i,0,n-1)print(B[i]);
return Ot(),0;
}