Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: D - I Wanna Win The Game
- // Contest: AtCoder - AtCoder Regular Contest 116
- // URL: https://atcoder.jp/contests/arc116/tasks/arc116_d
- // Memory Limit: 1024 MB
- // Time Limit: 2000 ms
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <assert.h>
- #include <bits/stdc++.h>
- #include <atcoder/modint>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&... values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
- template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
- template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
- template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using vi = vector<int>;
- using ll = long long;
- using pii = pair<int, int>;
- using mint = atcoder::modint998244353;
- const int mod = 998244353;
- int n, m;
- vi f;
- mint comb(int n, int r)
- {
- /*
- static auto dp = vv<int>(5001);
- if (dp[n][r] != 0)
- return dp[n][r];
- assert(n >= r);
- int step = min(r, n - r);
- mint ans = 1, ub = n, lb = r;
- for (int i = 0; i < step; ++i) {
- ans *= ub / lb;
- --ub, --lb;
- }
- dp[n][r] = ans.val();
- return ans;
- */
- static vi dp(5001);
- if (dp[0] == 0) {
- dp[0] = 1;
- for (int i = 1; i <= n; ++i) {
- for (int j = i; j > 0; --j)
- dp[j] = (dp[j] + dp[j - 1]) % mod;
- }
- }
- return dp[r];
- }
- int getf(int x)
- {
- if (f[x] != -1)
- return f[x];
- if (x % 2)
- return f[x] = 0;
- mint ans = 0;
- /*
- WA
- for (int i = min(x, n); i >= 0; i -= 2) {
- ans += getf((x - i) / 2) * comb(n, i);
- }
- */
- // AC
- for (int i = 0; i <= min(x, n); i += 2) {
- ans += mint(getf((x - i) / 2)) * comb(n, i);
- }
- return f[x] = ans.val();
- }
- int main(int argc, char **argv)
- {
- cin >> n >> m;
- f = vi(m + 1, -1);
- f[0] = 1;
- if (m % 2) {
- cout << 0 << endl;
- return 0;
- }
- int ans;
- for (int i = 2; i <= m; ++i)
- ans = getf(i);
- cout << ans << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement