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