QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395488 | #6736. Alice and Bob | frozen_wjl | TL | 0ms | 0kb | C++23 | 769b | 2024-04-21 15:20:00 | 2024-04-21 15:20:00 |
answer
#include<cmath>
#include<iostream>
#define mod 998244353
#define ll long long
#define N 10000005
using namespace std;
ll fac[N],inv1[N];
ll inv(ll t)
{
return t == 1 ? 1 : (mod - mod / t) * inv(mod % t) % mod;
}
void init()
{
int n = N-3;
fac[0] = 1;
inv1[0] = 1;
for (int i = 1;i <= n;++i)
fac[i] = fac[i - 1] * i % mod, inv1[i] = inv(i) * inv1[i - 1] % mod;
inv1[n] = inv(fac[n]);
}
ll A(ll a, ll b)
{
ll ret = 0;
if (b >= a)
return fac[a];
return fac[a] * inv1[a - b] % mod;
}
int main()
{
int n;
ll ans = 0;
cin >> n;
init();
for (int i = 0;i < n;++i)
{
if (n - 1 - i < i)
break;
else ans = (ans + A(n - 1 - i, i) * A(n - 1 - i, n - 1 - i) % mod) % mod;
}
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1