#include using namespace std; #include using namespace atcoder; using mint=modint998244353; #include using namespace __gnu_pbds; using ll = long long; vector is_prime; vector Q_enum; vector> POW; unordered_map ID; vector DI; void enum_prime(ll N){ ll sq=sqrt(N); POW.resize(sq+1); is_prime.assign(sq+1,1); is_prime[0]=is_prime[1]=0; for(ll i=0;i<=sq;i++){ if(is_prime[i]){ for(ll j=i*2;j<=sq;j+=i)is_prime[j]=0; ll r=1; int s=0; while(r<=N){ s+=(r%3); POW[i].push_back(s%3); r*=i; } } } return; } vector sm,bg; void calc_Qenum(ll N){ ll sq=sqrt(N); sm.assign(sq+1,-1); bg.assign(sq+1,-1); for(int i=1;i<=sq;i++){ Q_enum.emplace_back(N/i); bg[N/(N/i)]=ID.size(); ID[N/i]=ID.size(); DI.push_back(N/i); } while(Q_enum.back()>1){ sm[Q_enum.back()-1]=ID.size(); ID[Q_enum.back()-1]=ID.size(); DI.push_back(Q_enum.back()-1); Q_enum.emplace_back(Q_enum.back()-1); } return; } ll A,B; mint sum_n(ll n,ll c){ if(c==1){ return (n+2)/3-1; } if(c==2)return (n+1)/3; else if(c==0)return n/3; return 1; } vector calc_Fprime(ll N){ ll sq=sqrt(N); int sz=Q_enum.size(); vector F_pr(sz); for(int j=0;j INV(100,1); //f(p^e) auto g_calc=[](ll p,ll e){ return INV[e+1]; }; vector Min_sieve(ll N,function fn,vector F_pr){ int sz=Q_enum.size(); vector L_DP(sz); for(int i=0;i1;x--){ if(is_prime[x]){ int y=(x<=sq?sm[x]:bg[N/(x)]);; for(int i=0;i>N>>M; swap(N,M); for(int i=1;i<100;i++){ INV[i]=mint(i).pow(M); } Q_enum.clear(); ID.clear(); DI.clear(); calc_Qenum(N); vector FP=calc_Fprime(N); for(auto &p:FP)p*=INV[2]; vector G_DP=Min_sieve(N,g_calc,FP); cout<<(G_DP[ID[N]]+1).val()<