Submission #1211042

#TimeUsernameProblemLanguageResultExecution timeMemory
1211042nguynRack (eJOI19_rack)C++20
In queue
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define F first
#define S second
#define pb push_back 
#define pii pair<int,int>

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int n, k;

signed main(){
    ios_base::sync_with_stdio(false) ; 
    cin.tie(0) ; cout.tie(0) ; 
    if (fopen("INP.INP" ,"r")) {
        freopen("INP.INP" ,"r" , stdin) ;
        freopen("OUT.OUT" , "w" , stdout) ;
    }
    cin >> n >> k;
    if (n <= 20) {
	    vector<int> cur;
	    cur.pb(1); 
	    for (int i = (1 << (n - 1)); i >= 1; i >>= 1) {
	    	int sz = cur.size();
	    	for (int j = 0; j < sz; j++) {
	    		cur.pb(cur[j] + i); 
	    	}
	    }
	    // for (int i : cur) {
	    // 	cout << i << ' '; 
	    // }
	    cout << cur[k - 1]; 
    }
}