QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368346#6736. Alice and BobDelisha21UWA 1ms3816kbC++171014b2024-03-27 01:11:082024-03-27 01:11:08

Judging History

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

  • [2024-03-27 01:11:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2024-03-27 01:11:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10;
const int mod = 998244353;

queue<int> q;

void solve()
{
	int n;
	cin >> n;

	int ans = 1;
	for (int i = 1; i <= (n - n % 2) / 2; i++)
	{
		ans = (ans * i) % mod;
	}
	ans = (ans * ans) % mod;
	for (int i = 2 - n % 2; i <= (n - n % 2) / 2; i++)
	{
		q.push(i);
	}
	
	int sum = 0;
	for (int i = 1; i <= (n + 1) / 2; i++)
	{
		sum = (sum + ans) % mod;
		// cout << sum << endl;
		if (q.size() == 1)
		{
			ans = ans / q.front();
			ans = (ans * (q.back() + 1)) % mod;
			q.pop();
		}
		else if (q.size() >= 2)
		{
			ans = ans / q.front();
			
			q.pop();
			q.push(q.back() + 1);

			ans = (ans * q.back()) % mod;

			ans = (ans * q.back()) % mod;

			ans = ans / q.front();
			
			q.pop();
		}
	}
	cout << sum;
	return;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

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

input:

100

output:

335769205

result:

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