/
agc058d.test.cpp
46 lines (36 loc) · 906 Bytes
/
agc058d.test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define PROBLEM "https://atcoder.jp/contests/agc058/tasks/agc058_d"
#include "my_template.hpp"
#include "other/io.hpp"
#include "poly/convolution.hpp"
#include "poly/coef_of_rational_fps_2d.hpp"
using mint = modint998;
void solve() {
LL(A, B, C);
ll N = A + B + C;
using poly = vc<mint>;
vc<poly> F(2), G(4);
F[0] = {mint(3)};
F[1] = {mint(-1)};
G[0] = {mint(1)};
G[1] = {mint(-1)};
G[3] = {mint(0), mint(2)};
auto g = coef_of_rational_fps_2d(F, G, N);
FOR(i, len(g)) g[i] *= inv<mint>(2);
g[0] = 1;
mint ANS = 0;
FOR(t, len(g)) {
ll a = A - t, b = B - t, c = C - t;
if (min({a, b, c}) < 0) break;
mint cf = fact<mint>(a + b + c) * fact_inv<mint>(a) * fact_inv<mint>(b)
* fact_inv<mint>(c);
ANS += g[t] * cf;
}
print(ANS);
}
signed main() {
cout << fixed << setprecision(15);
ll T = 1;
// LL(T);
FOR(T) solve();
return 0;
}