이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |