#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 |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
1408 KB |
Output is correct |
10 |
Correct |
4 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
1408 KB |
Output is correct |
10 |
Correct |
4 ms |
4480 KB |
Output is correct |
11 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |