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 int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int fp(int a,int b){
if(b==0)return 1;
int t=fp(a,b/2);
t=(t*t)%MOD;
if(b%2)return (t*a)%MOD;
return t;
}
int32_t main(){
int n,k;
cin>>n>>k;
int ans=1,x=fp(2,n-1);
k--;
for(int i=1;i<=1e18;i*=2){
if(k&i){
ans=(ans+x)%MOD;
}
x=(x*fp(2,MOD-2))%MOD;
}
cout<<ans<<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... |