# 前言

clytql当场秒掉此题可惜不知道为什么fst了。

# 题解

$f_i(x) = \sum_{j\geq 0, j\bmod 2 = s_i} p_i ^ j \frac {x^ j } { j !} \\ = \frac 1 2 (e ^ {p_i x } + (-1)^{s_i} e ^ {-p_i x })$

$F(x) = \prod_i f_i(x) ,f(x) = \sum_{i} i! [x^i]F(x)$$k$ 次项系数就是随机按 $k$ 次开关到达指定状态的概率。

$\frac{\rm d} { {\rm d} x } \left ( \frac {f(x)}{g(x)}\right )$

$\cfrac{\rm d} { {\rm d} x } \left ( \cfrac {f(x)}{g(x)} \right ) = \cfrac{f'(x) g(x) - g'(x) f(x) }{g ^ 2(x)}$

$e ^ {kx} = \sum_{i\geq 0 } k ^ i \frac { x ^ i } { i ! }$

$\sum_{i\geq 0} k ^ i x ^ i= \frac{1}{1 - kx}$

$\cfrac{\rm d}{{\rm d}x}\left (\frac{1}{1 - kx}\right ) = \frac {k} { (1-kx) ^ 2}$

$\cfrac{f'(x) g(x) - g'(x) f(x) }{g ^ 2(x)}$

# 代码

#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
LL x=0,f=0;
char ch=getchar();
while (!isdigit(ch))
f|=ch=='-',ch=getchar();
while (isdigit(ch))
x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return f?-x:x;
}
const int N=105,S=1e5+10,mod=998244353;
int Pow(int x,int y){
int ans=1;
for (;y;y>>=1,x=(LL)x*x%mod)
if (y&1)
ans=(LL)ans*x%mod;
return ans;
}
if ((x+=y)>=mod)
x-=mod;
}
void Del(int &x,int y){
if ((x-=y)<0)
x+=mod;
}
return x>=mod?x-mod:x;
}
int Del(int x){
return x<0?x+mod:x;
}
int inv2=(mod+1)>>1;
int n;
int s[N],p[N],sum=0,invs;
int f[S],g[S],val[S],inv[N],O=5e4+5;
int ans=0;
void Get(int *a){
static int b[S];
For(i,-sum,sum){
a[i+O]=0;
val[i+O]=(LL)Del(i)*invs%mod;
inv[i+O]=Pow(Del(1-val[i+O]),mod-2);
}
a[0+O]=1;
For(i,1,n){
For(j,-sum,sum)
b[j+O]=0;
For(j,-sum,sum){
if (!a[j+O])
continue;
if (s[i])
Del(b[j-p[i]+O],a[j+O]);
else
}
For(j,-sum,sum)
a[j+O]=b[j+O];
}
}
int calc1(int *a,int *b){
// a' * b * (1 - x) ^ 2
int ans=0;
For(i,-sum,sum-1)
ans=(LL)ans*a[sum+O]%mod;
return ans;
}
int calc2(int *a){
return (LL)a[sum+O]*a[sum+O]%mod;
}
int main(){
For(i,1,n)