QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#402706#6736. Alice and Bobaltaires1#TL 0ms0kbC++14667b2024-05-01 11:20:162024-05-01 11:21:09

Judging History

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

  • [2024-05-01 11:21:09]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-05-01 11:20:16]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long
const int p=998244353;
const int N=1e7+5;
int fact[N],infact[N];

int qmi(int m,int k)
{
	int res=1%p,t=m;
	while(k)
	{
		if(k&1)res=res*t%p;
		t=t*t%p;
		k>>=1;
	}
	return res;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int res=0;
	int n;
	cin>>n;
	fact[0]=infact[0]=1;
	for(int i=1;i<N;i++)
	{
		fact[i]=fact[i-1]*i%p;
		infact[i]=infact[i-1]*qmi(i,p-2)%p;
	}
	for(int i=1;i<=n;i++)
	{
		if(n-i<i-1)continue;
		res=(res+fact[n-i]*infact[i-1]%p*infact[n-i-i+1]%p*fact[i-1]%p*fact[n-i]%p)%p;
	}
	cout<<res<<'\n';
	return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:

1

result: