2019 Multi-University Training Contest 2
Posted dongdong25800
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019 Multi-University Training Contest 2相关的知识,希望对你有一定的参考价值。
http://acm.hdu.edu.cn/search.php?action=listproblem
思路:ri/si为等级为i时升级成功的概率,si/ri就表示第si/ri次升级成功,而前面的(si/ri-1)次全部升级失败,用这样的方式计算期望。
#include<bits/stdc++.h> using namespace std; #define ll long long const int mod=1e9+7; const int maxn=5e5+10; ll power(ll a, ll b, ll p) ll ans=1%p; for(; b; b>>=1) if(b&1) ans=(long long)ans*a%p; a=(long long)a*a%p; return ans; ll sum[maxn]; int main() ios::sync_with_stdio(false); cin.tie(0); int tt; cin>>tt; while(tt--) ll n,q; cin>>n>>q; ll r,s,x,a; sum[1]=0; for(int i=1; i<=n; i++) cin>>r>>s>>x>>a; ll t=s*power(r,mod-2,mod)%mod; sum[i+1]=(sum[i]+(ll)t*a%mod+((ll)(t-1+mod)*((sum[i]-sum[x]+mod)%mod)%mod))%mod; for(int i=1; i<=q; i++) ll l,r; cin>>l>>r; cout<<(sum[r]-sum[l]+mod)%mod<<endl;
以上是关于2019 Multi-University Training Contest 2的主要内容,如果未能解决你的问题,请参考以下文章
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 3