QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352891#6736. Alice and Bobmonster7000RE 0ms0kbC++201.1kb2024-03-13 17:44:152024-03-13 17:44:15

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=998244353;
const int N=5e6+10;
int ac[N];
int inv[N];
int qmi(int a,int b)
{
	int res=1;
	a%=mod;
	while(b>0)
	{
		if(b&1)res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res%mod;
}
int ca(int n)
{
	ac[0]=1;
	inv[0]=1;
	for(int i=1;i<=n;i++)
	{
		ac[i]=ac[i-1]*i%mod;
		ac[i]=(ac[i]+mod)%mod;
		inv[i]=inv[i-1]*qmi(i,mod-2);
		inv[i]=(inv[i]+mod)%mod;
	//	cout<<i<<endl;
	}
	inv[n-1]=qmi(ac[n-1],mod-2);
	for(int i=n-2;i>=1;i--)
	{
		inv[i]=inv[i+1]*(i+1)%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(n);
	//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*inv[n-2*i+1]%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: