#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int maxn = 1e6 + 6;
const int mod = 1e9 + 7;
int n, k, p[maxn];
int calc(int n, int k) {
if(n == 0) {
return k;
}
int ans = calc(n - 1, (k + 1) / 2);
if(k % 2 == 0) {
ans += p[n - 1];
if(ans >= mod) ans -= mod;
}
return ans;
}
void solve() {
cin >> n >> k;
cout << calc(n, k);
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
p[0] = 1;
for(int i = 1; i < maxn; ++i) {
p[i] = p[i - 1] + p[i - 1];
if(p[i] >= mod) {
p[i] -= mod;
}
}
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |