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;
const int Mod = 1e9+7;
long long lgput(int b, int e)
{
long long p=1;
while(e)
{
if(e%2==1)
{
e--;
p=(1LL*p*b)%Mod;
}
else
{
e/=2;
b=(1LL*b*b)%Mod;
}
}
return p;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long n,k;
cin>>n>>k;
long long rez=1;
while(k!=1)
{
--n;
if(k%2==0)
{
rez+=lgput(2,n);
rez%=Mod;
}
k=(k+1)/2;
}
cout<<rez<<'\n';
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... |