이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |