QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#412452 | #6736. Alice and Bob | XiaoretaW# | TL | 0ms | 0kb | C++14 | 1.1kb | 2024-05-16 14:34:46 | 2024-05-16 14:34:47 |
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 998244353;
namespace Comb{
const int N = 1e7 + 1;
int fact[N], infact[N];
int power(int a, int b) {
int res = 1;
while (b) {
if (b & 1) res = 1ll * res * a % mod;
a = 1ll * a * a % mod;
b >>= 1;
}
return res;
}
void Init() {
fact[0] = 1;
infact[0] = 1;
for (int i = 1; i < N; i++) {
fact[i] = 1ll * fact[i - 1] * i % mod;
infact[i] = 1ll * infact[i - 1] * power(i, mod - 2) % mod;
}
}
int C(int a, int b) {
return 1ll * fact[a] * infact[b] % mod * infact[a - b] % mod;
}
}
using namespace Comb;
int main() {
Init();
int n; cin >> n;
ll ans = 0;
for (int i = 1; i <= n; i++) {
// ll alice = 1ll * fact[i - 1] * fact[n - i] % mod;
// ans = (ans + (fact[n - 1] - alice + mod) % mod) % mod;
if (i - 1 <= n - i) {
ans = (ans + 1ll * fact[i - 1] * C(n - i, i - 1) % mod * fact[n - 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