QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#321820#8171. Colagrass8cowWA 1ms5900kbC++17759b2024-02-05 17:16:582024-02-05 17:16:58

Judging History

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

  • [2024-02-05 17:16:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5900kb
  • [2024-02-05 17:16:58]
  • 提交

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",(ans+mod)%mod),0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5900kb

input:

2 1

output:

1

result:

wrong answer 1st words differ - expected: '499122177', found: '1'