遇到数学的式子我们就先手玩10分钟,经验之谈
当(n=1)
(dfrac{1}{a})
当(n=2)
(dfrac{1}{a}left( dfrac{1}{a}+dfrac{1}{b} ight) +dfrac{1}{b}left( dfrac{1}{a}+dfrac{1}{b} ight))
化简一下就是(dfrac{1}{ab})
当(n=3)
我们枚举出来他们的全排列
a b c
a c b
b a c
b c a
c a b
c b a
(dfrac{1}{a}left( dfrac{1}{a}+dfrac{1}{b} ight) left( dfrac{1}{a}+dfrac{1}{b}+dfrac{1}{c} ight)+dfrac{1}{a}left( dfrac{1}{a}+dfrac{1}{c} ight) left( dfrac{1}{a}+dfrac{1}{c}+dfrac{1}{b} ight)+dfrac{1}{b}+( dfrac{1}{b}+dfrac{1}{a})+left( dfrac{1}{b}+dfrac{1}{a}+dfrac{1}{c} ight)+dfrac{1}{b}+( dfrac{1}{b}+dfrac{1}{c})+left( dfrac{1}{b}+dfrac{1}{a}+dfrac{1}{c} ight))
(+dfrac{1}{c}left( dfrac{1}{c}+dfrac{1}{a} ight) left( dfrac{1}{c}+dfrac{1}{a}+dfrac{1}{b} ight)+dfrac{1}{c}left( dfrac{1}{c}+dfrac{1}{b} ight) left( dfrac{1}{c}+dfrac{1}{b}+dfrac{1}{a} ight))
化简一下我们会得到(dfrac{1}{abc})
用我们的数学归纳法我们会得到推广的结论,答案就是(n)个数的乘积
但是由于乘积在分母上,所以我们需要用逆元这个工具将它翻到分子上
代码
#include<bits/stdc++.h>
using namespace std;
long long n;
long long x;
const int mod=998244353;
long long ans;
int qmi(int a,int b)
{
int res=1;
while(b)
{
if(b&1) ans=(long long)res*a%mod;
a=(long long)a*a%mod;
b>>=1;
}
return res;
}
int main()
{
scanf("%lld",&n);
scanf("%lld",&ans);
for(int i=2;i<=n;i++)
{
scanf("%lld",&x);
ans=(long long)ans*x%mod;
}
cout<<qmi(ans,mod-2)<<endl;
return 0;
}