close

https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=620

 

#include <iostream>

using namespace std;

int main()
{
    int n,D,I;

    while (cin >> n && n!=-1) {
        while(n--) {

            cin>>D>>I;
            int root = 1;
            for(int i=1; i<=D; i++)
            {
                if((I%2)==0){ 
                    root = 2*root+1; I=I/2;

                }else{  
                    root = 2*root; I = (I+1)/2;
                }
            }
            cout<<root/2<<endl;
        }
    }
    return 0;
}

arrow
arrow
    文章標籤
    Dropping Balls UVA679
    全站熱搜

    楓綺 發表在 痞客邦 留言(0) 人氣()