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;
int MOD= 1e9 + 7;
int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> pow_two;
	pow_two.push_back(1);
	long long at=1;
	for(int i=1;i<n;i++)
	{
		at*=2;
		at %= MOD;
		pow_two.push_back(at);
	}
	long long rez=1;
	long long step=1;
	while(k!=1)
	{
		if(k%2==0)
		{
			rez+=pow_two[n-step];
			rez %= MOD;
			k-=k/2;
			step++;
		}
		else {
			step++;
			k-=k/2;
		}
	}
	cout<<rez<<endl;
	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... |