[BJOI2019] 光线

传送门

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=Aai+AbiBai+AbiBbiBai.......
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=Aaik=1Bkbik
根据等比数列求和公式( ∣ 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=Aai1Bbi1
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+aiBai+aiBbiBai+aiBbiBbiBai......
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+ai2Bk=1Bkbik
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+ai2B1Bbi1

然后这道题就没什么了,我们可以提前预处理出 1 1 − B b i m o d   p \frac{1}{1-Bb_i}mod \ p 1Bbi1mod 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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值