uva 679 Dropping Balls

/* ***********************************************
Author        :xryz
Email         :523689985@qq.com
Created Time  :4-14 21:16:41
File Name     :DroppingBalls.cpp
************************************************ */

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main()
{
    int n,i,k,t,m;
    scanf("%d",&t);
    while(~scanf("%d",&n))
    {
        if(n==-1) break;
        scanf("%d",&m);
        k=1;
        for(i=0;i<n-1;i++)
        {
            if(m%2) {k=2*k;m=(m+1)/2;}
            else {k=2*k+1;m=m/2;}
        }
        printf("%d\n",k);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

posted @ 2015-04-15 20:36  xryz  阅读(79)  评论(0编辑  收藏  举报