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 <iostream>
#include <vector>
using namespace std;
#define int long long
const int mod=1e9+7;
int bin_exp(int n,int k){
if(!k)return 1;
int x=bin_exp(n,k/2);
x=(x*x)%mod;
if(k&1)return (x*n)%mod;
return x;
}
signed main(){
int n,x,cnt=1,ans=0;
cin>>n>>x;
x--;
while(x){
if(x&1)ans=(ans+bin_exp(2,n-cnt))%mod;
x/=2;
cnt++;
}
cout<<ans+1<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |