//#include #include using namespace std; typedef long long ll; typedef pair p; const int INF = 1e9; const ll LINF = ll(1e18) + 1; const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() #define debug(v) \ cout << #v << ":"; \ for (auto x : v) \ { \ cout << x << ' '; \ } \ cout << endl; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //cout<> d >> l >> r >> k; ll base = 1; ll lrank, rrank; ll count = 0; while (true) { base *= 2; if (l < base) { lrank = count; break; } count++; } base = 1; count = 0; while (true) { base *= 2; if (r < base) { rrank = count; break; } count++; } //cout << lrank << " " << rrank << "\n"; ll lcarank=0; while(lrank+rrank-2*lcarank>k&&lcarank<=min(lrank,rrank)){ lcarank++; } ll ans = 1; if(rrank+lrank==k+2*lcarank){ if(lrank==lcarank){ ans=(1< factm((1 << 20), 1); ll fact = 1; for (int i = 1; i < (1 << 20); i++) { fact *= i; fact %= MOD; factm[i] = fact; } for (int i = 1; i < d; i++) { ll now = pow(2, i); if (i == lrank && i == rrank) { ans *= factm[now-2]; ans %= MOD; } else if (i == lrank || i == rrank) { ans *= factm[now-1]; ans %= MOD; } else { ans *= factm[now]; ans %= MOD; } } cout << ans << "\n"; }