社区讨论
60求条
P11250[GESP202409 八级] 手套配对参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mhj34ysl
- 此快照首次捕获于
- 2025/11/03 19:57 4 个月前
- 此快照最后确认于
- 2025/11/03 19:57 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
/*====================*/
typedef long long ll;
/*====================*/
#define endl '\n'
/*====================*/
const int N=1e3+10;
/*====================*/
const int A=1e3+1;
/*====================*/
const int MOD=1e9+7;
/*====================*/
ll c[N][N];
void Init()
{
c[0][0]=1;
for(int i=1;i<=A;i++)
{
for(int j=1;j<=i;j++)
{
c[i][0]=1;
if(i==j)c[i][j]=1;
else c[i][j]=(c[i-1][j]%MOD+c[i-1][j-1]%MOD)%MOD;
}
}
}
/*====================*/
ll FastPow(int a,int b)
{
int res=1;
while(b)
{
if(b&1)(res*=a)%=MOD;
(a*=a)%=MOD;b>>=1;
}
return res;
}
/*====================*/
void Solve()
{
int n,m,k;
cin>>n>>m>>k;
if(m<2*k||m-2*k>n-k)
{
cout<<0<<endl;
return;
}
cout<<1LL*c[n][k]*c[n-k][m-2*k]%MOD*FastPow(2,m-2*k)%MOD<<endl;
}
/*====================*/
int main()
{
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int T=1;cin>>T;
Init();
while(T--)Solve();
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...