QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#386751 | #6736. Alice and Bob | Arnold_6# | RE | 0ms | 0kb | C++14 | 998b | 2024-04-11 19:50:14 | 2024-04-11 19:50:15 |
answer
# include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10, mod = 998244353;
typedef long long LL;
int n;
LL fact[N], infact[N], inv[N];
int qp(int a, int k)
{
int res = 1;
while(k)
{
if(k & 1) res = (LL)res * a % mod;
a = (LL) a * a % mod;
k >>= 1;
}
return res;
}
void init()
{
fact[0] = infact[0] = 1;
inv[1] = 1;
for(int i = 2; i < N; i ++) inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
for(int i = 1; i < N; i ++)
{
fact[i] = (LL)fact[i - 1] * i % mod;
infact[i] = (LL)infact[i - 1] * inv[i] % mod;
}
}
int A(int y, int x)
{
return (LL)fact[x] * infact[x - y] % mod;
}
int main()
{
init();
cin >> n;
LL res = 0;
for(int i = 1; i <= (n + 1) / 2; i ++)
{
LL ans = (LL)A(i - 1, n - i) * fact[n - i] % mod;
res = (res + ans) % mod;
}
cout << res << endl;
system("pause");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
1
output:
1