#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << ", " << p.second << ')'; } template::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pi; const int mxN = 1<<19, oo = 1e9; const long long MOD = 998244353; class mint { public: int d; mint () {d=0;} mint (long long _d) : d(_d%MOD){}; mint operator*(const mint& o) const { return ((ll)d*o.d)%MOD; } mint operator+(const mint& o) const { long long tmp = d+o.d; if(tmp>=MOD) tmp-=MOD; return tmp; } mint operator-(const mint& o) const { long long tmp = d-o.d; if(tmp<0) tmp+=MOD; return tmp; } mint operator^(long long b) const { mint tmp = 1; mint power = *this; while(b) { if(b&1) { tmp = tmp*power; } power = power*power; b/=2; } return tmp; } mint operator/(const mint& o) { return *this * (o^(MOD-2)); } bool operator==(const mint& o) { return d==o.d; } friend mint& operator+=(mint& a, const mint& o) { a.d+=o.d; if(a.d>=MOD) a.d-=MOD; return a; } }; typedef mint cd; void revperm(cd* in, int n) { for(int i=0,j=0;i> 1; (j ^= k) < k; k >>= 1); } } cd w[mxN+1]; // stores w^j for each j in [0,n-1] void precomp() { w[0] = 1; int pw = (MOD-1)/mxN; w[1] = mint(3)^pw; for(int i= 2;i<=mxN;++i) { w[i] = w[i-1]*w[1]; } } void fft(cd* in, int n, bool reverse=false) { int lg = __lg(n); assert(1<>s); for(int j=0;j polymul(vector a, vector b) { int n = a.size(), m = b.size(), ptwo = 1; while(ptwo<(n+m)) ptwo*=2; a.resize(ptwo), b.resize(ptwo); fft(a.data(),ptwo); fft(b.data(),ptwo); for(int i=0;i> dp; int m; vector fib; vector& solve(int n) { if(n==0) { return fib; } if(dp.count(n)) return dp[n]; int split = n/2; if(n%2==0) split=0; // jump of length 1 auto& ans = dp[n]; { auto& res = solve(split), &res2 = solve(n-split-1); ans = polymul(res,res2); } ans.resize(m+1); if(n-split-1>=1) { auto& res = solve(split), &res2 = solve(n-split-2); auto mul = polymul(res,res2); for(int i=0;i<=m;++i) ans[i]+=mul[i]*(1 + (n%2==1)); } return ans; } int main() { precomp(); fib = {1,1}; fib.resize(mxN); for(int i=2;i> n >> m; fib.resize(m+1); auto res = solve(n); cout << res[m].d << '\n'; }