QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#223834 | #7056. Chessboard | veg# | AC ✓ | 43ms | 35172kb | C++14 | 627b | 2023-10-22 17:43:11 | 2023-10-22 17:43:12 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
const int p=1e9+7;
using namespace std;
const int N=2e6+5;
ll jc[N],inv[N];
ll C(int x,int y) {
return jc[x]*inv[y]%p*inv[x-y]%p;
}
int main(){
jc[0]=1;
for(int i=1;i<=2e6;++i) {
jc[i]=1ll*jc[i-1]*i%p;
}
inv[1]=inv[0]=1;
for(int i=2;i<=2e6;++i) {
inv[i]=(p-p/i)*inv[p%i]%p;
}
for(int i=1;i<=2e6;++i) {
inv[i]=inv[i-1]*inv[i]%p;
}
int T; scanf("%d",&T);
while(T--) {
int n,m; scanf("%d%d",&n,&m);
if(n==1&&m==1) puts("1");
else if(n==1||m==1) puts("2");
else {
printf("%lld\n",4*C(n+m-2,n-1)%p);
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 24ms
memory: 35036kb
input:
4 1 3 3 2 3 3 4 4
output:
2 12 24 80
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 43ms
memory: 35172kb
input:
100000 15792 12672 9316 25840 2840 1766 6041 11358 24545 23695 6867 5451 20360 1937 16422 30090 29793 9605 10515 14761 21907 31360 15532 21121 28260 27461 2296 8459 15031 26552 21401 21622 27858 22934 7596 28278 12389 27492 7921 25054 7880 15269 31788 32625 18565 20560 15563 9461 30742 24193 17352 2...
output:
110567924 924670542 949970465 966074148 738866875 850972524 188501202 415300991 348587010 83136096 868751565 382630270 84169254 853440534 896111017 757449222 159729268 314963625 123541563 930525180 843770156 720106956 738036168 297993327 601767944 38907892 236214827 455317099 254577850 272370955 239...
result:
ok 100000 lines