fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. #define print(a) for(auto x : a) cout << x << " "; cout << endl
  6.  
  7. const int M = 998244353;
  8. const int N = 3e5+9;
  9. const int INF = 2e9+1;
  10. const int LINF = 2000000000000000001;
  11.  
  12. inline int power(int a, int b, int mod=M) {
  13. int x = 1;
  14. a %= mod;
  15. while (b) {
  16. if (b & 1) x = (x * a) % mod;
  17. a = (a * a) % mod;
  18. b >>= 1;
  19. }
  20. return x;
  21. }
  22.  
  23. template<const int mod>
  24. struct mint {
  25. int val;
  26. constexpr mint(long long x = 0) : val((x % mod + mod) % mod) {}
  27. explicit operator int() const { return val; }
  28. mint& operator+=(const mint &b) { val += b.val; val -= mod * (val >= mod); return *this; }
  29. mint& operator-=(const mint &b) { val -= b.val; val += mod * (val < 0); return *this; }
  30. mint& operator*=(const mint &b) { val = 1ll * val * b.val % mod; return *this; }
  31. mint& operator/=(const mint &b) { return *this *= b.inv(); }
  32. mint inv() const { int x = 1, y = 0, t; for(int a=val, b=mod; b; swap(a, b), swap(x, y)) t = a/b, a -= t * b, x -= t * y; return mint(x); }
  33. mint power(int b) const { mint a = *this, res(1); for(; b; a *= a, b /= 2) if(b & 1) res *= a; return res; }
  34. mint operator-() const { return val == 0 ? 0 : mod - val; }
  35. mint& operator++() { val = val == mod - 1 ? 0 : val + 1; return *this; }
  36. mint& operator--() { val = val == 0 ? mod - 1 : val - 1; return *this; }
  37. mint operator++(int32_t) { mint before = *this; ++*this; return before; }
  38. mint operator--(int32_t) { mint before = *this; --*this; return before; }
  39. friend mint operator+(const mint &a, const mint &b) {return mint(a) += b;}
  40. friend mint operator-(const mint &a, const mint &b) {return mint(a) -= b;}
  41. friend mint operator*(const mint &a, const mint &b) {return mint(a) *= b;}
  42. friend mint operator/(const mint &a, const mint &b) {return mint(a) /= b;}
  43. friend bool operator==(const mint &a, const mint &b) {return a.val == b.val;}
  44. friend bool operator!=(const mint &a, const mint &b) {return a.val != b.val;}
  45. friend bool operator<(const mint &a, const mint &b) {return a.val < b.val;}
  46. friend istream& operator>>(istream &in, mint &a) {return in >> a.val;}
  47. friend ostream& operator<<(ostream &os, const mint &a) {return os << a.val;}
  48. };
  49. using Mint = mint<M>;
  50.  
  51. namespace comb {
  52. int n(0);
  53. vector<Mint> _fac{1}, _invfac{1}, _inv{0};
  54. void init(int m) {
  55. m = min (m, M - 1);
  56. if (m <= n) return;
  57. _fac.resize(m + 1); _invfac.resize(m + 1); _inv.resize(m + 1);
  58. for (int i = n + 1; i <= m; i++) _fac[i] = _fac[i - 1] * i;
  59. _invfac[m] = _fac[m].inv();
  60. for (int i = m; i > n; i--) _invfac[i - 1] = _invfac[i] * i, _inv[i] = _invfac[i] * _fac[i - 1];
  61. n = m;
  62. }
  63. Mint fact(int m) { if (m > n) init(2 * m); return _fac[m]; }
  64. Mint invfact(int m) { if (m > n) init(2 * m); return _invfac[m]; }
  65. Mint inv(int m) { if (m > n) init(2 * m); return _inv[m]; }
  66. Mint nCr(int n, int r) { if (n < r || r < 0) return 0; return fact(n) * invfact(r) * invfact(n - r); }
  67. }
  68. using comb::fact;
  69. using comb::invfact;
  70. using comb::inv;
  71. using comb::nCr;
  72.  
  73.  
  74. //_ ***************************** START Below *******************************
  75.  
  76. //* MOD changed
  77. // const int M = 998244353;
  78.  
  79.  
  80. int consistency(int a, int b, int c){
  81.  
  82. int ans = 0;
  83.  
  84. //* a, b
  85. int x = min(a,b);
  86. int y = max(a,b);
  87. int res1 = 1;
  88. for(int i=1; i<=x; i++){
  89. int val = (int)(nCr(x, i) * nCr(y, i) * fact(i));
  90. res1 = (res1 + val)%M;
  91. }
  92.  
  93. //* b, c
  94. x = min(b,c);
  95. y = max(b,c);
  96. int res2 = 1;
  97. for(int i=1; i<=x; i++){
  98. int val = (int)(nCr(x, i) * nCr(y, i) * fact(i));
  99. res2 = (res2 + val)%M;
  100. }
  101.  
  102. //* a, c
  103. x = min(a,c);
  104. y = max(a,c);
  105. int res3 = 1;
  106. for(int i=1; i<=x; i++){
  107. int val = (int)(nCr(x, i) * nCr(y, i) * fact(i));
  108. res3 = (res3 + val)%M;
  109. }
  110.  
  111. int res = (res1 * ((res2 * res3)%M) ) % M;
  112.  
  113. return res;
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. int practice(int a, int b, int c){
  131.  
  132.  
  133. return 0;
  134. }
  135.  
  136.  
  137.  
  138.  
  139.  
  140. void solve() {
  141.  
  142. int a, b, c;
  143. cin >> a >> b >> c;
  144.  
  145.  
  146. cout << consistency(a, b, c) << endl;
  147.  
  148.  
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155. int32_t main() {
  156. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  157.  
  158. int t = 1;
  159. // cin >> t;
  160. while (t--) {
  161. solve();
  162. }
  163.  
  164. return 0;
  165. }
Success #stdin #stdout 0s 5320KB
stdin
1 2 2
stdout
63