This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define modder 1000000007LL
vector<int> power2Mod;
int solve(int n, int k)
{
	if (n == 0)
		return 1;
	if (k % 2LL) // k is odd -> left subtree
		return solve(n - 1LL, (k + 1LL) / 2LL);
	else
		return (solve(n - 1, k / 2) + power2Mod[n - 1]) % modder;
}
signed main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	power2Mod = vector<int>(n, 1);
	for (int i = 1; i < n; i++)
	{
		power2Mod[i] = (power2Mod[i - 1] * 2) % modder;
	}
	cout << solve(n, k);
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |