#include #if __has_include() #include #endif using namespace std; #define done(...) return pp(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);ivoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ #define use_ml998244353 using ml=atcoder::modint998244353; namespace my{ auto&operator<<(ostream&o,const atcoder::modint998244353&x){return o<<(int)x.val();} void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} void lin(auto&...a){(cin>>...>>a);} templateusing pack_back_t=tuple_element_t>; } namespace my{ templateconcept vectorial=is_base_of_v::value_type>,remove_cvref_t>; templateconstexpr int depth=0; templateconstexpr int depth =depth+1; templatestruct core_t_helper{using type=T;}; templatestruct core_t_helper{using type=typename core_t_helper::type;}; templateusing core_t=core_t_helper::type; templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ static constexpr int D=depth+1; using C=core_t; using vector::vector; vec(const auto&...a)requires(sizeof...(a)>=3){resizes(a...);} void resizes(const auto&...a){if constexpr(sizeof...(a)==D){ }else*this=make(a...);} static auto make(ll n,const auto&...a){ if constexpr(sizeof...(a)==1)return vec(n,array{a...}[0]); else return vec(n,make(a...)); } }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } namespace my{entry void main(){ LL(C,X); use_ml998244353 if(X==0)done((ml)1/(C+1)); // https://yukicoder.me/problems/no/2105/editorial // 累積mexがXとならない // ⇔0,1,2,...,X-1が全て揃わないか,0,1,2,...,X-1が揃う前にXが出る // であるここで, // N→\inftyとすると,任意の数xについて,それが一度も現れない確率は0となる. // よって,この下で, // 累積mexがXとならない⇔0,1,2,...,X-1が揃う前にXが出る // である.この確率はXが0,1,2,...,XのX+1個の中でXが最後以外で出る確率で,1-1/(X+1). // X-C個目まではX未満しか出ず,それ以降はX以上が出る. // X-C個目までにX未満がj種類出る確率をq_jとすると,求める確率は // \sum_{n=0}^{X} q_j*(X-C個までに出ていないX-j種類の数とXの中で,Xが最後以外で出る確率) // \sum_{n=0}^{X} q_j*(1-1/(X-j+1)) // である. if(X<=C)done(1-ml(1)/(X+1)); // 初めからXが出得るとき. ll M=X-C; vec dp(M+1,X+1,ml{}); // dp[i][j]:i個まででX未満がj種類出ている確率. dp[0][0]=1; fo(i,M){ fo(j,X+1){ dp[i+1][j]+=dp[i][j]*((ml)j/(C+i+1)); if(j+1<=X)dp[i+1][j+1]+=dp[i][j]*(1-(ml)j/(C+i+1)); } } ml ans=0; fo(j,X+1)ans+=dp[M][j]*(1-(ml)1/(X-j+1)); pp(ans); }}