QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397422#2568. MountainsNaganohara_YoimiyaWA 1ms3776kbC++141.5kb2024-04-24 07:41:122024-04-24 07:41:13

Judging History

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

  • [2024-04-24 07:41:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3776kb
  • [2024-04-24 07:41:12]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define mk make_pair
#define fi first
#define se second

using namespace std;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int mod=998244353;
int ksm(int x,ll y,int p=mod){
	int ans=1;y%=(p-1);
	for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
	return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}

template<typename T>void cmax(T &x,T v){x=max(x,v);}
template<typename T>void cmin(T &x,T v){x=min(x,v);}

const int N=3e6+5;
int n,m,k,fac[N],ifac[N],Inv[N];
void init(int V){
	fac[0]=1;for(int i=1;i<=V;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[V]=inv(fac[V]);for(int i=V-1;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	for(int i=1;i<=V;i++)Inv[i]=1ll*fac[i-1]*ifac[i]%mod;
}

ll C2(int x){
	if(x<=1)return 0ll;
	return 1ll*x*(x-1)/2;
}

signed main(void){

#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
#endif

	n=read(),m=read(),k=read();
	int ans=1;init(n+m+k);
	for(int i=3;i<=n+m+k;i++){
		ll cc=C2(i-1)-C2(i-n-1)-C2(i-m-1)-C2(i-k-1)+C2(i-n-m-1)+C2(i-n-k-1)+C2(i-m-k-1);
		ans=1ll*ans*ksm(1ll*Inv[i-2]%mod*(i-1)%mod,cc)%mod;
	}
	cout<<ans<<endl;

	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3596kb

input:

1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

2 2 2

output:

20

result:

ok 1 number(s): "20"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

2 3 4

output:

490

result:

ok 1 number(s): "490"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

1 2 8

output:

45

result:

ok 1 number(s): "45"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1 10 2

output:

66

result:

ok 1 number(s): "66"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

9 5 7

output:

292544959

result:

wrong answer 1st numbers differ - expected: '371850968', found: '292544959'