Loj 3093 光线 Posted on 2020-01-09 | Views: 等比数列求和. 显然可以从前往后不断合并两面镜子,对于每面镜子只需要记录从前面射来的透光率和后面射来的反射率就可以了. 合并两面镜子时,推一下就能发现是个简单的等比数列求和. 时间复杂度 $O(n\log P)$ . 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051//%std#include<bits/stdc++.h>#define endl '\n'using namespace std;typedef long long ll;inline int read(){ int out=0,fh=1; char jp=getchar(); while ((jp>'9'||jp<'0')&&jp!='-') jp=getchar(); if (jp=='-') fh=-1,jp=getchar(); while (jp>='0'&&jp<='9') out=out*10+jp-'0',jp=getchar(); return out*fh;}const int P=1e9+7;int add(int a,int b){ return (a+b>=P)?(a+b-P):(a+b);}int mul(int a,int b){ return 1LL * a * b % P;}int fpow(int a,int b){ int res=1; while(b) { if(b&1) res=mul(res,a); a=mul(a,a); b>>=1; } return res;}int main(){ int n=read(),A=1,B=0,Inv=fpow(100,P-2); for(int i=1;i<=n;++i) { int a=mul(read(),Inv),b=mul(read(),Inv); int tmp=fpow(add(1,P-mul(B,b)),P-2); A=mul(A,mul(a,tmp)); B=add(b,mul(B,mul(a,mul(a,tmp)))); } cout<<A<<endl; return 0;}