NC237149. Card
描述
输入描述
The input consists of multiple test cases.The first line contains a single integer - the number of test cases. Description of the test cases follows.
each test case contains 3 intergers
输出描述
For each test case, print the expectation, modulo
示例1
输入:
3 3 0 0 1 1 1 10000 10000 10000
输出:
3 166666668 921053954
C++ 解法, 执行用时: 4ms, 内存消耗: 464K, 提交时间: 2022-06-05 18:01:17
#include<bits/stdc++.h> using namespace std; const int mod=1e9+7; int kpow(int x,int y,int rex=1){ for(;y;y>>=1,x=1ll*x*x%mod)if(y&1)rex=1ll*x*rex%mod; return rex; } void work(){ int c,s,b; cin>>c>>s>>b; int x=(s+b)?1ll*s*kpow(s+b,mod-2)%mod:1; cout<<1ll*c*kpow(s+b+1,mod-2)%mod*x%mod<<endl; } int main(){ int T; cin>>T; while(T--)work(); return 0; }