QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#399346 | #6736. Alice and Bob | Kidding_Ma | WA | 86ms | 159912kb | C++14 | 1.1kb | 2024-04-26 10:58:08 | 2024-04-26 10:58:09 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
constexpr int P = 998244353;
i64 *fac, *ifac;
i64 power(i64 a, i64 b, int p = P) {
i64 res = 1;
for (; b; b >>= 1, a = a * a % p) {
if (b & 1) {
res = res * a % p;
}
}
return res;
}
i64 inv(i64 x) {
return power(x, P - 2, P);
}
void init(int N) {
fac = new i64 [N + 1];
ifac = new i64 [N + 1];
fac[0] = 1;
for (int i = 1; i <= N; i++) {
fac[i] = fac[i - 1] * i % P;
}
ifac[N] = inv(fac[N]);
for (int i = N - 1; i >= 0; i--) {
ifac[i] = ifac[i + 1] * (i + 1) % P;
}
}
i64 C(int n, int m) {
if (m < 0 || m > n || n < 0) {
return 0;
}
return fac[n] * ifac[m] % P * ifac[n - m] % P;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
init(1E7);
int n;
cin >> n;
i64 ans = 0;
for (int i = 1; i <= n; i++) {
ans = (ans + C(n - i, i - 1) * C(n - i, n - i) % P) % P;
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 83ms
memory: 159912kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 83ms
memory: 159828kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 86ms
memory: 159896kb
input:
10
output:
55
result:
wrong answer 1st numbers differ - expected: '997920', found: '55'