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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const ll mod = 1e9+7;
ll f(ll n, ll k) {
if (n==0) return 1;
if (n<=62 && k>(1ll<<n)/2) {
return 2ll*f(n-1,k-(1ll<<n)/2);
} else {
return 2ll*f(n-1,k)-1;
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,k;
cin>>n>>k;
ll res = 0;
--k;
for (int i=0; i<n; i++) {
res=2ll*res%mod+(k%2)%mod;
k /= 2;
}
res++;
res %= mod;
res += mod;
res %= mod;
cout<<res;
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... |