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;
typedef long long ll;
ll expo(ll x, ll n, ll m){
if(n==0)return 1;
ll u=expo(x,n/2,m);
u=(u*u)%m;
if(n%2)u=(u*x)%m;
return u;
}
int main (){
long long n,k;
cin>>n>>k;
n--;
long long start;
if(n>59)
start=1;
else{
ll temp=1e18;
ll res=expo(2,n,temp);
if(k<=res)
start=1;
else{
start=2;
k-=res;
}
}
//cout<<start<<endl;
int mod=1e9+7;
while(k>(ll)1){
if(k%2){
k/=2;
k++;
}
else{
k/=2;
start+=expo(2,n,mod);
start%=mod;
}
n--;
}
cout<<start<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |