(f_i)光穿透(i)层玻璃并允许在其中不停反射的概率
SOL:
(p_i)射穿i层玻璃的概率
(q_i)i层玻璃后反射回来的概率
[p_i=p_{i-1}a_isum_{k=0}^{oo}(q_{i-1}b_i)^k
]
[q_i=b_i+q_{i-1}a_i^2sum_{k=0}^{oo}(q_{i-1}b_i)^k
]
[sum_{k=0}^{oo}x^k=frac1{1-x}
]
最终递推式
[p_i=frac{p_{i-1}a_i}{1-q_{i-1}b_i}
]
[q_i=b_i+frac{q_{i-1}a_i^2}{1-q_{i-1}b_i}
]
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
return f==1?x:-x;
}
#define ll long long
const int mod=1e9+7;
inline int ksm(int x,int r){
int ret=1;
for(int i=0;(1ll<<i)<=r;i++){
if((r>>i)&1)ret=(ll)ret*x%mod;
x=(ll)x*x%mod;
}
return ret;
}
int n,p=1,q;
int main(){
n=read();
for(int i=1,a,b,x,inv100=ksm(100,mod-2);i<=n;i++){
a=(ll)read()*inv100%mod;b=(ll)read()*inv100%mod;
x=ksm((mod+1-(ll)q*b%mod)%mod,mod-2);
p=(ll)p*a%mod*x%mod;
q=((ll)q*a%mod*a%mod*x+b)%mod;
}
cout<<p;
return (0-0);
}