QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352836#6736. Alice and Bobmonster7000RE 0ms0kbC++20978b2024-03-13 17:19:142024-03-13 17:19:14

Judging History

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

  • [2024-03-13 17:19:14]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-13 17:19:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=998244353;
const int N=5e6+10;
int ac[N];
int qmi(int a,int b)
{
	int res=1;
	a%=mod;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res%mod;
}
int ca(int n)
{
	ac[0]=1;
	for(int i=1;i<=n;i++)
	{
		ac[i]=ac[i-1]*i%mod;
		ac[i]=(ac[i]+mod)%mod;
	}
}
int a(int n,int m)
{
	int aa=1;
	for(int i=n;m>=1;i--,m--)
	{
		aa=aa%mod*i%mod;
		aa=(aa+mod)%mod;
	}
//	cout<<"aa:"<<aa<<endl;
	return (aa+mod)%mod;
	
}
signed main()
{
	int n;
	cin>>n;
	ca(5e6);
	//for(int i=1;i<=4;i++)cout<<ac[i]<<endl;
	int ans=0;
	for(int i=1;i*2<=n+1;i++)
	{
	//	cout<<"a[i] "<<ac[n-i]<<" "<<ac[n-i+1]<<endl;
		int tt=ac[n-i]%mod*qmi(ac[n-2*i+1],mod-2)%mod;
	//	cout<<"i2:"<<tt<<endl;
		tt=(tt+mod)%mod;
		tt=tt*ac[n-i]%mod;
		tt=(tt+mod)%mod;
	//	cout<<"i:"<<tt<<endl;
		ans=(ans+tt)%mod;
		ans=(ans+mod)%mod;
	}
	cout<<(ans+mod)%mod<<endl;;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

1

output:


result: