Submission #1287563

#TimeUsernameProblemLanguageResultExecution timeMemory
1287563JohanRack (eJOI19_rack)C++20
0 / 100
1 ms644 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int binpow(int a,int b) {
  int res=1;
  while(b>0){
    if(b&1){
      res=res*a;
    }
    a=a*a;
    b>>=1;
  }
  return res;
}
void solve(){
  int n;
  cin>>n;
  int x;
  cin>>x;
  int pov=binpow(2,n-1);
  if(x<=pov){
    if(x%2==1){
      cout<<x;
    }
    else{
      cout<<x+pov-1;
    }
  }
  else{
    if(x%2==0){
      cout<<x;
    }
    else{
      cout<<x-pov+1;
    }
  }
}
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;//cin>>t;
  while(t--){
    solve();
    cout<<endl;
  }
}//
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...