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;
typedef long long ll;
const ll N=(2e5)+10;
const ll num=(1e9)+7;
vector<ll> p(60, 1);
void power(){
for(ll i=1; i<60; i++){
p[i]=p[i-1]*2;
}
}
ll solve(ll n, ll k){
if(k==1) return 1;
if(n==1) return k;
if(n>=61){
return (2*solve(n-1, k)-1)%num;
}
else{
if(k>p[n-1]){
return (2*solve(n-1, k-p[n-1]))%num;
}
else{
return (2*solve(n-1, k)-1)%num;
}
}
}
int main(){
ll n, k;
cin>>n>>k;
power();
cout<<solve(n, k);
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... |