QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417194 | #6678. Gem Island 2 | RedreamMer | RE | 5ms | 8692kb | C++17 | 1.9kb | 2024-05-22 16:01:08 | 2024-05-22 16:01:08 |
Judging History
answer
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <random>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
#define PB emplace_back
#define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }
const int N = 2e5, mod = 998244353;
int fac[N + 5], inv[N + 5];
int qp(int n, int m = mod - 2) {
int res = 1;
for (; m; m >>= 1) {
if (m & 1) res = res * n % mod;
n = n * n % mod;
}
return res;
}
void init() {
fac[0] = fac[1] = 1;
rep(i, 2, N) fac[i] = fac[i - 1] * i % mod;
inv[N] = qp(fac[N]);
per(i, N - 1, 0) inv[i] = inv[i + 1] * (i + 1) % mod;
}
int C(int n, int m) {return fac[n] * inv[m] % mod * inv[n - m] % mod;}
int a, b, c, f[N + 5];
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
init();
cin >> a >> b >> c;
rep(i, 1, a) for(int j = 0; j * i <= b; ++j) (f[i] += C(b - j * i + a - 1, a - 1));
rep(i, 1, a) f[i] %= mod;
int ans = 0;
auto sg = [&] (int x) {return x & 1 ? mod - 1 : 1;};
if(c == 1) {
rep(i, 1, c) rep(j, c, a) (ans += sg(j - i) * C(j - 1, i - 1) % mod * C(a, j) % mod * f[j]) %= mod;
}
else {
(ans += a % mod * f[1]) %= mod;
rep(j, c + 1, a) {
(ans += sg(j - c) * C(j - 2, c - 1) % mod * C(a, j) % mod * f[j]) %= mod;
}
}
cout << ans * qp(C(b + a - 1, a - 1)) % mod;
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 8692kb
input:
2 3 1
output:
499122180
result:
ok 1 number(s): "499122180"
Test #2:
score: 0
Accepted
time: 3ms
memory: 6996kb
input:
3 3 2
output:
698771052
result:
ok 1 number(s): "698771052"
Test #3:
score: 0
Accepted
time: 3ms
memory: 7252kb
input:
5 10 3
output:
176512750
result:
ok 1 number(s): "176512750"
Test #4:
score: 0
Accepted
time: 2ms
memory: 7052kb
input:
5 4 3
output:
71303175
result:
ok 1 number(s): "71303175"
Test #5:
score: 0
Accepted
time: 3ms
memory: 8504kb
input:
37 47 12
output:
962577218
result:
ok 1 number(s): "962577218"
Test #6:
score: 0
Accepted
time: 3ms
memory: 7260kb
input:
29 50 26
output:
175627840
result:
ok 1 number(s): "175627840"
Test #7:
score: 0
Accepted
time: 3ms
memory: 7124kb
input:
298 498 221
output:
765832019
result:
ok 1 number(s): "765832019"
Test #8:
score: 0
Accepted
time: 3ms
memory: 8408kb
input:
497 456 243
output:
414028615
result:
ok 1 number(s): "414028615"
Test #9:
score: 0
Accepted
time: 5ms
memory: 8020kb
input:
114514 1926 817
output:
691374994
result:
ok 1 number(s): "691374994"
Test #10:
score: -100
Runtime Error
input:
1919810 1554 1999