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>
#define ll long long
#define ff first
#define ss second
using namespace std;
ll p=1000000007;
ll logpow(ll v,ll e){
if(e==0)
return 1;
else{
if(e%2==0){
ll ans=logpow(v,e/2);
ans%=p;
ans=ans*ans;
ans%=p;
return ans;
}
else{
ll ans=logpow(v,e/2);
ans%=p;
ans=ans*ans;
ans%=p;
ans*=v;
ans%=p;
return ans;
}
}
}
int main(){
ll n,m;
cin>>n>>m;
ll v=1,cnt=0;
while(cnt!=n){
if(m%2==1)
v=2*v;
else
v=2*v+1;
v%=p;
if(m%2==0)
m=m/2;
else
m=m/2+1;
cnt++;
}
ll pow=logpow(2,n)-1;
pow%=p;
ll ans=v-pow;
if(ans<0)
ans=p-abs(ans);
cout<<ans;
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... |