QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#395488#6736. Alice and Bobfrozen_wjlTL 0ms0kbC++23769b2024-04-21 15:20:002024-04-21 15:20:00

Judging History

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

  • [2024-04-21 15:20:00]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-21 15:20:00]
  • 提交

answer

#include<cmath>
#include<iostream>
#define mod 998244353
#define ll long long
#define N 10000005
using namespace std;

ll fac[N],inv1[N];
ll inv(ll t)
{
	return t == 1 ? 1 : (mod - mod / t) * inv(mod % t) % mod;
}

void init()
{
	int n = N-3;
	fac[0] = 1;
	inv1[0] = 1;
	for (int i = 1;i <= n;++i)
		fac[i] = fac[i - 1] * i % mod, inv1[i] = inv(i) * inv1[i - 1] % mod;
	inv1[n] = inv(fac[n]);
}
ll A(ll a, ll b)
{
	ll ret = 0;
	if (b >= a)
		return fac[a];
	return fac[a] * inv1[a - b] % mod;
}
int main()
{
	int n;
	ll ans = 0;
	cin >> n;
	init();
	
	for (int i = 0;i < n;++i)
	{
		if (n - 1 - i < i)
			break;
		else ans = (ans + A(n - 1 - i, i) * A(n - 1 - i, n - 1 - i) % mod) % mod;
	}
	cout << ans << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: