病毒扩散----------------------------思维(组合数学)

50 篇文章 0 订阅
7 篇文章 0 订阅

在这里插入图片描述.在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
解析:
如果在t时刻走到(x,y) ,那么一定走x次 就是C(t,x) 那么剩下的y次就是C(t-x,y)

所以方案数就是: C(t,x)*C(t-x,y)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10000;
const int MOD=998244353;
ll fact[N];
int t,x,y,n;
ll quick(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
void init()
{
	fact[0]=1;
	for(int i=1;i<=N;i++) fact[i]=(fact[i-1]*i)%MOD;
}
int main()
{	
	init();
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d %d %d",&x,&y,&t);
		if(x+y>t) 
		{
			cout<<0<<endl;
			continue;
		}
		cout<<fact[t]%MOD*quick(fact[t-x]*fact[x]%MOD,MOD-2)%MOD*fact[t-x]%MOD*quick(fact[t-x-y]*fact[y]%MOD,MOD-2)%MOD<<endl;	
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值