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;
/*
000 001 010 011 100 101 110 111
1 5 3 7 2 6 4 8
*/
ll solve(int n, ll k) {
if (n == 1) {
return k;
}
ll base = 1ll<<(n-1), k_reves = 0;
k -= 1;
while (base) {
k_reves += (k%2) * base;
k /= 2;
base /= 2;
}
return k_reves + 1;
}
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
int n;
ll k;
cin >> n >> k;
cout << solve(n, k) << "\n";
cout.flush();
return EXIT_SUCCESS;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |