Advertisement
pb_jiang

ARC116d WA

Nov 30th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. // Problem: D - I Wanna Win The Game
  2. // Contest: AtCoder - AtCoder Regular Contest 116
  3. // URL: https://atcoder.jp/contests/arc116/tasks/arc116_d
  4. // Memory Limit: 1024 MB
  5. // Time Limit: 2000 ms
  6. //
  7. // Powered by CP Editor (https://cpeditor.org)
  8.  
  9. #include <assert.h>
  10. #include <bits/stdc++.h>
  11. #include <atcoder/modint>
  12.  
  13. using namespace std;
  14. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  15. template <typename... Args> void logger(string vars, Args &&... values)
  16. {
  17.     cerr << vars << " = ";
  18.     string delim = "";
  19.     (..., (cerr << delim << values, delim = ", "));
  20.     cerr << endl;
  21. }
  22.  
  23. template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
  24. template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
  25. template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
  26. template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
  27.  
  28. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  29. using vi = vector<int>;
  30. using ll = long long;
  31. using pii = pair<int, int>;
  32. using mint = atcoder::modint998244353;
  33.  
  34. const int mod = 998244353;
  35. int n, m;
  36. vi f;
  37.  
  38. mint comb(int n, int r)
  39. {
  40.     /*
  41.     static auto dp = vv<int>(5001);
  42.     if (dp[n][r] != 0)
  43.         return dp[n][r];
  44.     assert(n >= r);
  45.     int step = min(r, n - r);
  46.     mint ans = 1, ub = n, lb = r;
  47.     for (int i = 0; i < step; ++i) {
  48.         ans *= ub / lb;
  49.         --ub, --lb;
  50.     }
  51.     dp[n][r] = ans.val();
  52.     return ans;
  53.     */
  54.     static vi dp(5001);
  55.     if (dp[0] == 0) {
  56.         dp[0] = 1;
  57.         for (int i = 1; i <= n; ++i) {
  58.             for (int j = i; j > 0; --j)
  59.                 dp[j] = (dp[j] + dp[j - 1]) % mod;
  60.         }
  61.     }
  62.     return dp[r];
  63. }
  64.  
  65. int getf(int x)
  66. {
  67.     if (f[x] != -1)
  68.         return f[x];
  69.     mint ans = 0;
  70.     /*
  71.     for (int i = min(x, n); i >= 0; i -= 2) {
  72.         ans += getf((x - i) / 2) * comb(n, i);
  73.     }
  74.     */
  75.     for (int i = 0; i <= min(x, n); i += 2) {
  76.         ans += getf((x - i) / 2) * comb(n, i);
  77.     }
  78.     return f[x] = ans.val();
  79. }
  80.  
  81. int main(int argc, char **argv)
  82. {
  83.     cin >> n >> m;
  84.     f = vi(m + 1, -1);
  85.     f[0] = 1;
  86.     if (m % 2) {
  87.         cout << 0 << endl;
  88.         return 0;
  89.     }
  90.     int ans = getf(m);
  91.     for (int i = 0; i <= m; ++i)
  92.         dbg(f[i]);
  93.     cout << ans << endl;
  94.     return 0;
  95. };
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement