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 main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
ll mod = 1e9+7;
ll n, k;
cin >> n >> k;
ll pos = 1, add = n;
bool inv = false;
for (int i = 0; i < min(n, 1LL * 63); i++) {
add--;
if (inv == false) {
if ((k & (1 << i))) {
inv = 1;
} else {
pos |= (1 << add);
pos %= mod;
}
} else {
if ((k & (1 << i))) {
pos |= (1 << add);
pos %= mod;
} else {
inv = 1;
}
}
}
cout << pos << '\n';
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... |