# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999886 | vjudge1 | Rack (eJOI19_rack) | C++17 | 0 ms | 348 KiB |
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 ll long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
const int MAX = 2e5+1;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,m;
cin >> n >> m;
ll cnt = 0;
char c;
ll keep = 0;
ll add, sub;
ll b,bb;
b = (1<<(n-1));
bb = (1<<(n-2));
if((1<<n)/2<m){
m-= (1<<n)/2;
if(m%2==0){
add = (m/4) *bb +2+b;
// cout <<
sub =(1^((m+1)%2)) * bb;
cout << add+ sub<< endl;
}
else{
add = ((m/4)) *bb +2;
if(m>2) sub =(1^((m+1)%2)) * bb;
else sub = 0;
cout << add+ sub<< endl;
}
}
else{
if(m%2==0){
add = (m/4) *bb +1+b;
// cout <<
sub =(1^((m+1)%2)) * bb;
cout << add+ sub<< endl;
}
else{
add = ((m/4)) *bb +1;
if(m>2) sub =(1^((m+1)%2)) * bb;
else sub = 0;
cout << add+ sub<< endl;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |