#include <bits/stdc++.h>
#define ar array
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int mod = 1e9 + 7;
const ll inf = 1e18;
const int N = 1e6 + 5;
ll pw[N];
signed main() {
pw[0] = 1;
for(int i=1; i<N; i++)
pw[i] = (pw[i-1] * 2) % mod;
ll ans = 1;
int n, m; cin >> n >> m;
ll len = 1; m--;
for(int b=min(n-1, 61); b>=0; b--) {
if(m % (len << 1) >= len) ans = (ans + pw[b]) % mod;
len <<= 1;
}
cout << ans << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |