#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; } int get_msb(ll m){ for(int i = 60; i >= 0; i--){ if(m&(1ll<> m; m--; if(m == 0){ cout << 1 << endl; return 0; } int msb = get_msb(m); auto dp = vec2d(msb+1, 2, mint(0)); dp[msb][1] = 1; for(int i = msb-1; i >= 0; i--){ int cur_bit = m&(1ll< cur_bit) continue; int same_next = [&](){ if(same == 0) return 0; if(z < cur_bit) return 0; return 1; }(); // cout << same << ' ' << x << ' ' << y << ' ' << same_next << ' ' << dp[i+1][same] << endl; ll r = ((1ll<