#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint998244353; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } #define N_MAX 2000002 mint inv[N_MAX],fac[N_MAX],finv[N_MAX]; void init(){ const ll MOD = mint::mod(); fac[0]=1;fac[1]=1; finv[0]=1;finv[1]=1; inv[1]=1; for(int i=2;i; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; init(); ll n, m; cin >> n >> m; m = abs(m); if(m == 0){ mint ans = 0; if(n%2 == 0){ ans += comb(n, n/2)*mint(2).pow(n)*2; for(int i = 0; i <= n; i+=2){ int j = n-i; ans -= comb(n, i)*comb(n-i, j)*comb(i, i/2)*comb(j, j/2); } } ans /= mint(4).pow(n); cout << ans << endl; return 0; } ll sum = 0; mint ans = 0; auto f = [&](ll x, ll y){ mint ans = 0; for(int i = x; i <= n; i++){ int j = n-i; if(j < y) continue; if(i%2 != x%2) continue; if(j%2 != y%2) continue; ans += comb(n, i)*comb(i, (i-x)/2)*comb(j, (j-y)/2); } return ans; }; set

st; for(ll X = 1; X*X <= m; X++){ if(m%X != 0) continue; ll Y = m/X; if(X%2 != Y%2) continue; ll x = abs(X-Y)/2; ll y = abs(X+Y)/2; if(x+y > n) continue; sum++; st.insert({x, y}); st.insert({y, x}); } for(auto [x, y]: st) { if(x*x - y*y != m) continue; mint p = f(x, y); if(x != 0) p *= 2; if(y != 0) p *= 2; ans += p; } ans /= mint(4).pow(n); cout << ans << endl; }