Submission #216706

#TimeUsernameProblemLanguageResultExecution timeMemory
216706MODDIRack (eJOI19_rack)C++14
40 / 100
5 ms384 KiB
#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%MOD);
	int at=1;
	for(int i=1;i<n;i++)
	{
		at*=2;
		at %= MOD;
		pow_two.push_back(at);
	}
	int rez=1;
	int step=1;
	while(k!=1)
	{
		if(k%2==0)
		{
			rez+=pow_two[n-step];
			k-=k/2;
			step++;
		}
		else {
			step++;
			k-=k/2;
		}
	}
	cout<<rez<<endl;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...