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;
#define endl '\n'
#define ll long long
const ll sz=2e5+5, mod=1e9+7;
ll power(ll a, ll b)
{
if(b==0) return 1;
ll temp=power(a, b/2);
if(b%2==0){
return temp%mod*temp%mod;
}
return (temp%mod*temp%mod*a)%mod;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, k;
cin>>n>>k;
ll j=n-1, ans=0;
//cout<<power(2, 3)<<' ';
if(k==1){
cout<<1;
return 0;
}
while(k>1){
if(k%2==0){
ans+=power(2, j);
ans%=mod;
}
k=(k+1)/2;
j--;
}
cout<<ans+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |