QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#368574 | #6736. Alice and Bob | liutaowoaini | WA | 1ms | 3652kb | C++17 | 809b | 2024-03-27 13:14:17 | 2024-03-27 13:14:18 |
Judging History
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'