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 ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pi pair<int, int>
#define pii pair<pair<int, int>, int>
#define piii pair <int, pair<int, int>>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5;
const long long oo = 1e18;
vector <int> v;
int main() {
int n, k;
cin >> n >> k;
int h = pow(2, n - 1);
v.resize(h + 1);
bool b = false;
if(k % 2 == 0){
k--;
b = true;
}
v[1] = 1;
v[2] = h + 1;
for(int i = 1;i <= h;i++){
if(i % 2 == 1){
v[i] = (v[i / 2 + 1] + 1) / 2;
}
else{
v[i] = v[i-1] + h;
}
if(v[i] == k){
if(b) cout << h + i;
else cout << i;
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... |