从1开始遍历,有ai/100的概率进入下一个下标
100-ai/100的概率从头开始
问多少次可以到达n+1
设dp[i]为从i-1到达i的期望次数
dp方程为下
sum是从1到达i-1的期望步数
然后都算出来之后我们都加起来就好了
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
#define int long long
const int INF = 4e18+5;
#define F(i,l,r) for(int i=l;i<=r;i++)
#define R(i,l,r) for(int i=r;i>=l;i--)
#define vv vector
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
const int mod = 998244353;
//const int mod = 1e9+7;
const int M = 1e7+5;
int a[N],b[N],c,d,vis[N],pri[N],ans1[N],ans2[N],dp[N],p[N][4];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m,k,ans,x,y,n0,n2,m0,m2,op,op1,op2;
string s;
map<pii,int>mp;
map<int,int>mmap;
//char mp[1005][1005];
//vector<int>v1[N],v2[N];
int lowbit(int x) {
return x&-x;
}
char xx[N];
bool temp;
int kuai(int x,int y){
int sum=1;
x%=mod;
while(y){
if(y%2){
y--;
sum*=x;
sum%=mod;
}
x*=x;
y/=2;
x%=mod;
}
return sum;
}
struct node{
int shu;
int id;
}jie[N];
bool cmp(node x,node y){
return x.shu<y.shu;
}
void solve()
{
cin>>n;
F(i,1,n) cin>>a[i];
int sum=0;
dp[1]=0;//成功到达1;
F(i,2,n+1){
dp[i]=(100-a[i-1])*kuai(100,mod-2)%mod*sum%mod+1;
dp[i]=dp[i]*100%mod*kuai(a[i-1],mod-2)%mod;
sum+=dp[i]; sum%=mod;
}
ans=0;
F(i,1,n+1) ans+=dp[i],ans%=mod;
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0); // cin.tie(nullptr);
int T = 1;
//cin >> T;
for (int i = 1; i <= T; i++)
{
solve();
}
return 0;
}
/*
6 4 3 1 2
1 1 4 5 1 4
*/