QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#321822#8171. Colagrass8cowRE 1ms5976kbC++17773b2024-02-05 17:17:262024-02-05 17:17:28

Judging History

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

  • [2024-02-05 17:17:28]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5976kb
  • [2024-02-05 17:17:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,jc[10010000],ij[10010000];
const int mod=998244353;
int qpow(int a,int b){
	int c=1;
	for(;b;b>>=1){
		if(b&1)c=1ll*a*c%mod;
		a=1ll*a*a%mod;
	}
	return c;
}
int C(int a,int b){if(a<0||b<0||a<b)return 0;return 1ll*jc[a]*ij[b]%mod*ij[a-b]%mod;} 
int Z(int x){
	if(x<0)return 0;
	return C(x+n,n);
}
int main(){
	scanf("%d%d",&n,&m);m--;
	jc[0]=1;int O=n*2;
	for(int i=1;i<=O;i++)jc[i]=1ll*i*jc[i-1]%mod;
	ij[O]=qpow(jc[O],mod-2);
	for(int i=O;i;i--)ij[i-1]=1ll*i*ij[i]%mod;
	int ans=Z(m);
	for(int k=1;k*(k*3-1)/2<=m;k++){
		(ans+=((k&1)?-1:1)*Z(m-k*(k*3-1)/2))%=mod;
		(ans+=((k&1)?-1:1)*Z(m-k*(k*3+1)/2))%=mod;
	}
	//(1-x-x^2+x^5+x^7-)
	return printf("%d",(1ll*ans*ij[n]%mod+mod)%mod),0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1

output:

499122177

result:

ok "499122177"

Test #2:

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

input:

1 1

output:

1

result:

ok "1"

Test #3:

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

input:

167 91

output:

469117530

result:

ok "469117530"

Test #4:

score: -100
Runtime Error

input:

9806463 8975779

output:


result: