QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#152519 | #5039. Black and White | vme50 | WA | 11ms | 11776kb | C++20 | 803b | 2023-08-28 10:59:40 | 2023-08-28 10:59:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define N 1000005
#define MOD 998244353
int T,n,m,c,ans,fc[N],invFc[N];
int qPow(int x,int y)
{int res=1;for(;y;y/=2,x=1ll*x*x%MOD) if(y&1) res=1ll*res*x%MOD;return res;}
void init(int n)
{
fc[0]=invFc[0]=1;for(int i=1;i<=n;++i) fc[i]=1ll*fc[i-1]*i%MOD;
invFc[n]=qPow(fc[n],MOD-2);
for(int i=n-1;i;--i) invFc[i]=1ll*invFc[i+1]*(i+1)%MOD;
}
int bn(int x,int y) {return x<y?0:1ll*fc[x]*invFc[y]%MOD*invFc[x-y]%MOD;}
void slv()
{
scanf("%d %d %d",&n,&m,&c);if(n>m) swap(n,m);c+=n/2;ans=0;
if(c<0 || c>n) {printf("0\n");return;}
for(int i=0,t;i<=n;++i)
{
t=i?1ll*bn(n-c-1,(i-1)/2)*bn(c,i/2)%MOD:n==c;
ans=(ans+1ll*bn((n+m+i)/2,n)*t)%MOD;
}printf("%d\n",ans);
}
int main() {scanf("%d",&T);init(1e6);while(T--) slv();return 0;}
详细
Test #1:
score: 100
Accepted
time: 11ms
memory: 11640kb
input:
5 1 1 0 1 1 -1 2 2 1 2 2 0 4 4 1
output:
1 0 1 4 16
result:
ok 5 number(s): "1 0 1 4 16"
Test #2:
score: 0
Accepted
time: 11ms
memory: 11776kb
input:
100 1 1 -10 1 1 -9 1 1 -8 1 1 -7 1 1 -6 1 1 -5 1 1 -4 1 1 -3 1 1 -2 1 1 -1 1 1 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 2 -10 1 2 -9 1 2 -8 1 2 -7 1 2 -6 1 2 -5 1 2 -4 1 2 -3 1 2 -2 1 2 -1 1 2 0 1 2 1 1 2 2 1 2 3 1 2 4 1 2 5 1 2 6 1 2 7 1 2 8 1 2 9 1 2 10 1 3 -10 1 3 -9 1 3 -...
output:
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0 0 0 0
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 7ms
memory: 11716kb
input:
100 1 5 6 1 5 7 1 5 8 1 5 9 1 5 10 1 6 -10 1 6 -9 1 6 -8 1 6 -7 1 6 -6 1 6 -5 1 6 -4 1 6 -3 1 6 -2 1 6 -1 1 6 0 1 6 1 1 6 2 1 6 3 1 6 4 1 6 5 1 6 6 1 6 7 1 6 8 1 6 9 1 6 10 1 7 -10 1 7 -9 1 7 -8 1 7 -7 1 7 -6 1 7 -5 1 7 -4 1 7 -3 1 7 -2 1 7 -1 1 7 0 1 7 1 1 7 2 1 7 3 1 7 4 1 7 5 1 7 6 1 7 7 1 7 8 1 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 7ms
memory: 11668kb
input:
100 1 10 1 1 10 2 1 10 3 1 10 4 1 10 5 1 10 6 1 10 7 1 10 8 1 10 9 1 10 10 2 1 -10 2 1 -9 2 1 -8 2 1 -7 2 1 -6 2 1 -5 2 1 -4 2 1 -3 2 1 -2 2 1 -1 2 1 0 2 1 1 2 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 2 -10 2 2 -9 2 2 -8 2 2 -7 2 2 -6 2 2 -5 2 2 -4 2 2 -3 2 2 -2 2 2 -1 2 2 0 2 2 1 2 2 ...
output:
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 6 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 9 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
wrong answer 20th numbers differ - expected: '1', found: '0'