#line 2 "/home/sakflat/CP/_library/cpp/template/template.cpp" //yukicoder@cpp17 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; const ll MOD = 998244353; const ll MODx = 1000000007; const int INF = (1<<30)-1; const ll LINF = (1LL<<62LL)-1; const double EPS = (1e-10); P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}}; P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; template vector make_vector(size_t a, T b) { return vector(a, b); } template auto make_vector(size_t a, Ts... ts) { return vector(a, make_vector(ts...)); } /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる 計算量は変わらないが楽できるシリーズ min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ /* comment outed because can cause bugs __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } */ #line 2 "/home/sakflat/CP/_library/cpp/template/basic.cpp" #line 1 "/home/sakflat/CP/_library/cpp/data-structure/segment-tree/segment-tree.cpp" template< typename T, typename F> struct SegmentTree{ private: int n; vector node; F f; T initer; public: SegmentTree(int n_, F f, T initer) : f(f),initer(initer) { n = 1; while(n < n_)n*=2; node.resize(2*n-1, initer); } SegmentTree(int n_, F f,T initer, vector x) : f(f),initer(initer) { n = 1; while(n < n_)n*=2; node.resize(2*n-1, initer); set(x); } void set(vector x){ for(int i = 0; (int)x.size() > i; i++){ update(i,x[i]); } } void update(int x, T val){ x += (n-1); node[x] = val; while(x > 0){ x = (x-1)/2; node[x] = f(node[2*x+1],node[2*x+2]); } } void add(int x, T val){ x += (n-1); node[x] += val; while(x > 0){ x = (x-1)/2; node[x] = f(node[2*x+1],node[2*x+2]); } } T getf(int a,int b, int k=0, int l=0, int r=-1){ if(r < 0){ r = n-1; } if(r < a || b < l){ return initer; } if(a <= l && r <= b){ return node[k]; } T vl = getf(a,b,2*k+1,l,(l+r)/2); T vr = getf(a,b,2*k+2,(l+r)/2+1,r); return f(vl,vr); } void debug(){ int nw = 1; int curr = 1; cout << "---begin---" << endl; for(int i = 0; 2*n-1 > i; i++){ cout << node[i] << " "; if(nw == curr)cout << endl,nw *= 2, curr=1; else curr++; } cout << "---end---" << endl; } }; template SegmentTree get_segment_tree(int N, const F &f, T initer){ return SegmentTree{N,f,initer}; } template SegmentTree get_segment_tree(int N, const F &f, T initer, vector x){ return SegmentTree{N,f,initer,x}; } #line 2 "/home/sakflat/CP/_library/cpp/data-structure/mod-int/mod-int.cpp" template struct ModInt{ int n; ModInt():n(0){} ModInt(long long n_):n(n_ >= 0 ? n_%mod : mod - ((-n_)%mod) ){} ModInt(int n_):n(n_ >= 0 ? n_%mod : mod - ((-n_)%mod) ){} ModInt &operator+=(const ModInt &p){ if((n+=p.n) >= mod)n-=mod; return *this; } ModInt &operator-=(const ModInt &p){ n+=mod-p.n; if(n >= mod)n-=mod; return *this; } ModInt &operator*=(const ModInt &p){ n = (int) ((1LL*n*p.n)%mod); return *this; } ModInt &operator/=(const ModInt &p){ *this *= p.inverse(); return *this; } ModInt operator-() const {return ModInt(-n);} ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;} ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;} ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;} ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;} bool operator==(const ModInt &p) const {return n==p.n;} bool operator<(const ModInt &p) const {return n(const ModInt &p) const {return n>p.n;} bool operator>=(const ModInt &p) const {return n>=p.n;} bool operator<=(const ModInt &p) const {return n<=p.n;} bool operator!=(const ModInt &p) const {return n!=p.n;} ModInt inverse() const { int a = n,b = mod,u = 1,v = 0; while(b){ int t = a/b; a -= t*b; swap(a,b); u -= t*v; swap(u,v); } return ModInt(u); } ModInt pow(int64_t z) const { ModInt ret(1),mul(n); while(z > 0){ if(z & 1) ret *= mul; mul *= mul; z >>= 1; } return ret; } int getMod() const { return mod; } friend ostream &operator<<(ostream &os, const ModInt &p){ return os << p.n; } friend istream &operator>>(istream &is, ModInt &a){ int64_t t; is >> t; a = ModInt ((long long)t); return (is); } }; using mint = ModInt; int main(){ long long n,l;cin>>n>>l; auto seg = get_segment_tree(n+1, [](mint a, mint b){return a+b;}, (mint)0); for(int i = 1; min(l,n) >= i; i++){ seg.add(i, (mint)1); } for(int i = 1; n >= i; i++){ auto z = seg.getf(max(0LL,i-l), i-1); seg.add(i, z); } cout << seg.getf(n,n) << endl; return 0; }