【题目链接】:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2135
【题意】
【题解】
答案应该为
但是要特判一些为0的情况吧
比如
a>n
b>m
以及
当a+b==n+m的时候,k< a+b
当a+b< n+m的时候k!=a+b
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,x,y) for (int i = x;i <= y;i++)
#define LL long long
const int N = 20+5;
int n,m,a,b,k;
LL c[N][N];
int main()
{
//freopen("D:\rush.txt","r",stdin);
rep1(i,0,20)
{
c[i][i] = c[i][0] = 1;
}
rep1(i,2,20)
rep1(j,1,i-1)
c[i][j] = c[i-1][j]+c[i-1][j-1];
int T;
cin >> T;
while (T--)
{
cin >> n >> m >> k >> a >> b;
if (a>n || b>m)
{
puts("0 1");
continue;
}
if (a+b==n+m)
{
if (k>=(a+b))
puts("1 1");
else
{
puts("0 1");
continue;
}
}
else
{
//a+b<n+m
if (k!=(a+b))
{
puts("0 1");
continue;
}
else
{
LL fz = c[n][a]*c[m][b],fm = c[n+m][a+b];
LL divisor = __gcd(fz,fm);
fz/=divisor,fm/=divisor;
cout << fz << ' ' << fm<<endl;
}
}
}
return 0;
}