Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
885 B
7
Indexable
Never
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 105
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define Ford(i,a,b) for ( int i = a; i >= b; i-- )
#define MOD 100000000000007

using namespace std;
int k,n;
long long luythua(int x,int y)
{
    if(y == 0) return 1;
    if(y % 2 == 0)
    {
        long long half = luythua(x,y/2);
        return half * half;
    }
    else return x * luythua(x,y - 1);
}
int Find(int n)
{
    int res = 1,lop = 1;
    Ford(i,k,1)
    if(n > luythua(2,i-1))
    {
        lop *= 2;
        res = lop - res + 1;
        n = luythua(2,i) - n + 1;
    } else lop *= 2;
    return res;
}
void inp()
{
    cin >> k >> n;
}
void solve()
{
   cout << Find(n);
}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai1.inp","r")){
        freopen("bai1.inp","r",stdin);
    }
    inp();
    solve();
}
Leave a Comment