QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#386734 | #6736. Alice and Bob | Arnold_6# | TL | 0ms | 0kb | C++14 | 854b | 2024-04-11 19:44:07 | 2024-04-11 19:44:07 |
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];
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;
for(int i = 1; i < N; i ++)
{
fact[i] = (LL)fact[i - 1] * i % mod;
infact[i] = qp(fact[i], mod - 2);
}
}
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;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1