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;
#define int long long
class ConstSizeVector {
	public:
		ConstSizeVector(int size) : v(size), totalsize(size) {}
		
		void pb(int n) {
			v[currsize] = n;
			currsize++;
		}
		
		int get(int i) {
			return v[i];
		}
		
		int getSize() {
			return currsize;
		}
		
	private:
		vector<int> v;
		int totalsize;
		int currsize = 0;
};
int mypow(int base, int exp) {
	int result = 1;
	
	for(int i = 1; i <= exp; i++) {
		result*=base;
	}
	
	return result;
}
signed main() {
	int n, k; cin >> n >> k;
	
	int totalOps = mypow(2, n);
	int tosubtractatend = 0;
	
	ConstSizeVector reversedOps (totalOps/2);
	
	if(k <= totalOps/2) {
		k+=totalOps/2;
		tosubtractatend = 1;		
	}
	
	
	reversedOps.pb(totalOps);
	while(totalOps - reversedOps.getSize() >= k) {
		int sizebefore = reversedOps.getSize();
		int tosubtract = totalOps/2/sizebefore;
		for(int i = 0; i < sizebefore; i++) {
			reversedOps.pb(reversedOps.get(i)-tosubtract);
		}
	}
	
	
	cout << reversedOps.get(totalOps/2 - (k-totalOps/2)) - tosubtractatend << "\n";
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |