ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#164629 | #2908. count | louhao088 | 100 | 34ms | 4288kb | C++11 | 1.2kb | 2022-11-05 11:01:26 | 2022-11-05 13:02:31 |
answer
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ls (rt<<1)
#define rs (rt<<1|1)
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define int long long
const int maxn=2e5+5,M=2e5+5,mod=1e9+7;
inline int read(){
char ch=getchar();bool f=0;int x=0;
for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;
for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
if(f==1){x=-x;}return x;
}
void print(int x){
static int a[55];int top=0;
if(x<0) putchar('-'),x=-x;
do{a[top++]=x%10,x/=10;}while(x);
while(top) putchar(a[--top]+48);
}
int n,m,fac[maxn],inv[maxn],T,ans=0;
int C(int x,int y){return fac[x]*inv[y]%mod*inv[x-y]%mod;}
void init(int n){
inv[0]=inv[1]=fac[0]=1;
for(int i=2;i<=n;i++)inv[i]=inv[mod%i]*(mod-mod/i)%mod;
for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
}
void solve(){
n=read(),m=read();
ans=C(n+m-2,m-1)*(n%mod*m%mod-1)%mod;
cout<<ans<<endl;
}
signed main(){
//freopen("1.in","r",stdin);
//freopen(".out","w",stdout);
T=read();init(200000);
while(T--)solve();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 10ms
memory: 4284kb
input:
10 1 1 2000 1997 117 1647 392 452 959 1883 1046 1627 1398 1124 1372 306 1799 1007 111 1765
output:
0 57631948 737963048 807538931 137760374 398194748 77480423 174938019 583393917 445670336
result:
ok 10 lines
Test #2:
score: 20
Accepted
time: 8ms
memory: 4288kb
input:
10 1 1 2000 1997 1218 1479 350 1244 784 1715 999 92 396 1393 1726 1511 624 756 900 317
output:
0 57631948 610566455 356523655 593949258 665757514 349394180 73375269 50652564 663822508
result:
ok 10 lines
Test #3:
score: 20
Accepted
time: 8ms
memory: 4288kb
input:
10 1 1 100000 99997 36934 50467 5497 37576 83775 15544 23817 68917 33052 49207 59924 39340 2708 2614...
output:
0 73866797 788834869 539491921 582239610 497376436 343937059 324406513 13225836 35059446
result:
ok 10 lines
Test #4:
score: 20
Accepted
time: 4ms
memory: 4284kb
input:
10 1 1 100000 99997 6792 14252 90281 65716 46434 67120 18977 30384 16191 33996 3425 10433 31783 4263...
output:
0 73866797 609230597 213203975 638117274 527713366 525065128 867713025 174019248 375031322
result:
ok 10 lines
Test #5:
score: 20
Accepted
time: 4ms
memory: 4284kb
input:
10 1 1 100000 99994 47270 99792 93093 92620 88764 20724 48143 99711 33293 89038 2816 16811 97638 670...
output:
0 796648553 5720713 279796657 802039459 22848874 23038351 610731858 629891152 812026839
result:
ok 10 lines