#include <iostream>
using namespace std;
#define endl '\n'
const long mod = 1000000007;
long long step(int n)
{
if(n==0)return 1;
else
{
long long res = 2;
for(int i = 2 ; i<=n ; i++)res=(2*res)%mod;
return res;
}
}
long long n,step1,curr,st,j,curr1,kof;
long long k;
int main()
{
ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k;
j = 1;
kof = 0;
while(k!=1)
{
if(k%2==0){kof+=step(n-j);k/=2;}
else
{
k/=2;
k++;
}
j++;
}
cout<<(kof+k)%mod;
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... |