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>
#define ll long long
#define MOD 1000000007
using namespace std;
ll square(ll n) {
return n*n;
}
ll pow2(ll n) {
if(n == 0) { return 1; }
return ((n%2)+1)*square(pow2(n/2));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin >> n >> k;
ll curr_pow = 1, total = 0;
for( ; n >= 60; n --) {
curr_pow = (curr_pow*2)%MOD;
}
for(ll i = pow2(n)/2; i > 0; i >>= 1) {
if(i < k) {
total = (total + curr_pow)%MOD;
k -= i;
}
curr_pow = (curr_pow*2)%MOD;
}
cout << (total+1) << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |