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;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,k,mod=1000000007LL,ka;
long long xar(long long q, long long w){
if(w==0) return 1LL;
long long qw=xar(q,w/2);
if(w%2==0) return (qw*qw); else return ((qw*qw)*q);
}
long long rec(long long q, long long w){
if(q==1){
return w;
}
if(q-1>=ka||xar(2,q-1)>=w){
return (rec(q-1,w)*2-1+mod)%mod;
}else{
return (rec(q-1,w-xar(2,q-1))*2)%mod;
}
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>k;
for(ka=1; ; ka++){
if(xar(2,ka)>=k) break;
}
cout<<rec(a,k);
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... |