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;
using ll =long long int;
using ull=unsigned long long;
/*I liked you once but not anymore now*/
int mod=1e9+7;
ll binpow(ll k)
{
ll res=1LL;
ll a=2LL;
while(k>0)
{
if(k%2==1)res=(res*a)%mod;
a=(a*a)%mod;
k/=2LL;
}
return res;
}
void solve(){
ll n,k;cin>>n>>k;
ll ans=1LL;
//if(k==1){cout<<1;return;}
while(k!=1)
{
n--;
if(k%2==0)
{
k=k/2LL;
ans+=binpow(n);
}
else{
k/=2LL;
k++;
}
ans%=mod;
}
cout<<ans;
return;
}
int main()
{
std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
solve();
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... |