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()
{
long long n, k;
cin>>n>>k;
vector<long long> pow_two;
pow_two.push_back(1);
long long at=1;
for(int i=1;i<n;i++)
{
at*=2;
at %= MOD;
if(at < 0)
return 0;
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;
if(rez < 0)
return 0;
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... |