zhei题…
小清新数论题
题意就不说了
思路是什么?
主要就是我们考虑,一层一层的合并,比如说,我们先把第2块的反射率和透射率算出来,然后再和第三块合成一块玻璃
然后再算,一直到第
n
n
n块玻璃
但是注意合并之后的玻璃上下表面的反射率是不一样的,所以我们只需要算下表面的反射率和上表面的透射率
然后就没了
下面来推式子
设
A
A
A是之前合并的玻璃的上表面的透射率,
B
B
B下表面的反射率
那么当我们合并第
i
i
i快玻璃的时候,就有
A
=
A
⋅
a
i
+
A
⋅
b
i
⋅
B
⋅
a
i
+
A
⋅
b
i
⋅
B
⋅
b
i
⋅
B
⋅
a
i
.
.
.
.
.
.
.
A=A\cdot a_i+A\cdot b_i\cdot B\cdot a_i+A\cdot b_i\cdot B\cdot b_i\cdot B\cdot a_i.......
A=A⋅ai+A⋅bi⋅B⋅ai+A⋅bi⋅B⋅bi⋅B⋅ai.......
A
=
A
⋅
a
i
⋅
∏
k
=
1
∞
B
k
b
i
k
A=A\cdot a_i\cdot \prod_{k=1}^\infty B^kb_i^k
A=A⋅ai⋅k=1∏∞Bkbik
根据等比数列求和公式(
∣
B
b
i
∣
<
1
|Bb_i|<1
∣Bbi∣<1)
A
=
A
⋅
a
i
⋅
1
1
−
B
b
i
A=A\cdot a_i\cdot \frac{1}{1-Bb_i}
A=A⋅ai⋅1−Bbi1
B
=
b
i
+
a
i
⋅
B
⋅
a
i
+
a
i
⋅
B
⋅
b
i
⋅
B
⋅
a
i
+
a
i
⋅
B
⋅
b
i
⋅
B
⋅
b
i
⋅
B
⋅
a
i
.
.
.
.
.
.
B=b_i+a_i\cdot B\cdot a_i+a_i\cdot B\cdot b_i\cdot B\cdot a_i+a_i\cdot B\cdot b_i\cdot B\cdot b_i\cdot B\cdot a_i......
B=bi+ai⋅B⋅ai+ai⋅B⋅bi⋅B⋅ai+ai⋅B⋅bi⋅B⋅bi⋅B⋅ai......
B
=
b
i
+
a
i
2
⋅
B
⋅
∏
k
=
1
∞
B
k
b
i
k
B=b_i+a_i^2\cdot B\cdot \prod_{k=1}^\infty B^kb_i^k
B=bi+ai2⋅B⋅k=1∏∞Bkbik
B
=
b
i
+
a
i
2
B
⋅
1
1
−
B
b
i
B=b_i+a_i^2B\cdot \frac{1}{1-Bb_i}
B=bi+ai2B⋅1−Bbi1
然后这道题就没什么了,我们可以提前预处理出 1 1 − B b i m o d p \frac{1}{1-Bb_i}mod \ p 1−Bbi1mod p这样可以节省一点时间
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <stack>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <ctime>
using namespace std;
# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)
typedef long long ll;
const int N=5e5+5;
const int inf=0x7fffffff;
const int mod=1e9+7;
template <typename T> void read(T &x){
x=0;int f=1;
char c=getchar();
for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
x*=f;
}
ll n,A,B,prec;
ll a[N],b[N];
ll f[N];
ll Qpow(ll base,ll ind){
ll res=1;
while(ind){
if(ind&1)res=res*base%mod;
base=base*base%mod;
ind>>=1;
}
return res;
}
int main()
{
read(n);
Rep(i,1,n)read(a[i]),read(b[i]);
prec=Qpow(100,mod-2);
Rep(i,1,n)a[i]=a[i]*prec%mod,b[i]=b[i]*prec%mod;
A=1,B=0;
Rep(i,1,n){
ll inv=Qpow((1-B*b[i]%mod+mod)%mod,mod-2);
A=A*a[i]%mod*inv%mod;
B=b[i]+a[i]*a[i]%mod*B%mod*inv%mod;
}
printf("%lld\n",A);
return 0;
}