QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628020#8792. CandiesmengzddWA 1507ms594728kbC++142.0kb2024-10-10 18:16:082024-10-10 18:16:10

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 18:16:10]
  • 评测
  • 测评结果:WA
  • 用时:1507ms
  • 内存:594728kb
  • [2024-10-10 18:16:08]
  • 提交

answer

#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=(j);i<=(k);++i)
#define NFOR(i,j,k) for(int i=(j);i>=(k);--i)
#define mkp make_pair
#define fst first
#define sec second
#define inl inline
#define pb push_back
#define el_phy_kongroo return 0
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned int ui;
typedef pair< int,int > pii;
inline int read()
{
	int s=0,w=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+ch-'0',ch=getchar();}
	return s*w;
}
void file()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
void teltim(int x)
{
	clock_t c1=0;
	if(x) c1=clock();
	else cerr<<endl<<clock()-c1<<"ms"<<endl;
}
const int N=1e5+5;
const ll mod=998244353;

int a,b,c;

namespace permutation
{
	ll fac[N],inv[N],facinv[N];
	bool hasinit;
	void init()
	{
		hasinit=1;
		fac[0]=fac[1]=inv[1]=facinv[0]=facinv[1]=1;
		FOR(i,2,N-5)
		{
			inv[i]=mod-mod/i*inv[mod%i]%mod;
			fac[i]=fac[i-1]*i%mod;
			facinv[i]=facinv[i-1]*inv[i]%mod;
		}
	}
	
	inl int C(int n,int m)
	{
		if(!hasinit) init();
		return fac[n]*facinv[m]%mod*facinv[n-m]%mod;	
	}
	
	inl int C(int x,int y,int z)
	{
		return C(x+y+z,x)*C(y+z,y)%mod;
	}
	
	inl int A(int n,int m)
	{
		if(!hasinit) init(); 
		return fac[n]*facinv[m]%mod;
	}
}
using namespace permutation;

const int n=1e4+5;

ll ans;
ll dp[n][n];

int main()
{
	//file();
	a=read(),b=read(),c=read();
	FOR(i,0,n-5) dp[i][0]=C(i<<1|1,i)*inv[i<<1|1]%mod;
	FOR(i,1,n-5)
	{
		FOR(j,1,i-1) dp[i][j]=(dp[i-1][j]+dp[j][j])%mod;
		dp[i][i]=2*inv[i]%mod;
	} 
	FOR(i,1,n-5)
	{
		int tmp1=i<<1|1,tmp2=i<<1|1;
		ll tmp=dp[i][0];
		FOR(j,1,i)
		{
			ll coef=tmp1*inv[tmp2]%mod;
			tmp=tmp*dp[i][j]%mod*coef%mod;
			dp[i][j]=tmp;
			tmp1++,tmp2-=2;
		}
	}

	ans=C(a,b,c)%mod;
	FOR(i,0,b-1) FOR(j,0,min(i,c))
	{
		ll sto=C(a-i,b-i-1,c-j)*dp[i][j]%mod;
		ans=(ans-sto+mod)%mod;
	}
	FOR(j,0,c-1) FOR(i,0,min(j,b))
	{
		ll sto=C(a-j,b-i,c-j-1)*dp[j][i]%mod;
		ans=(ans-sto+mod)%mod;
	}
	printf("%lld",ans);
	el_phy_kongroo;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 676ms
memory: 593116kb

input:

4 3 2

output:

368

result:

ok answer is '368'

Test #2:

score: -100
Wrong Answer
time: 1507ms
memory: 594728kb

input:

10000 10000 10000

output:

608394594

result:

wrong answer expected '905642282', found '608394594'