QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368574#6736. Alice and BobliutaowoainiWA 1ms3652kbC++17809b2024-03-27 13:14:172024-03-27 13:14:18

Judging History

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

  • [2024-03-27 13:14:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-03-27 13:14:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int mod = 998244353;
signed main()
{
	int n;
	cin >> n;
	int zhong = (n + 1) / 2;
	int ans = 1;
	for (int i = 1; i <= zhong; i++)
	{
		ans = (ans * i) % mod;
	}
	int jc = ans;
	int shu = 1;
	int cha = n - zhong-1;
	int a = 0, b = 0;
	for (int i = zhong; i >= 1; i--)
	{
		shu = (shu * i) % mod;
		if (cha == 2)b = i;
		else if (cha == 1)a = i;
		cha--;
		if (cha == 0) break;
	}
	ans = (ans * shu) % mod;
	//开始计算
	for (int i = zhong + 1; i <n; i++)
	{
		jc = (jc * i) % mod;
		if (i == n-1)
		{
			ans = (ans + jc) % mod;
		}
		else
		{
			shu = (shu / a / b * i) % mod;
			ans = (ans + (jc * shu) % mod) % mod;
		}
		a += 2;
		b += 2;
	}
	cout << ans << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3652kb

input:

100

output:

678331830

result:

wrong answer 1st numbers differ - expected: '188898954', found: '678331830'