首页 > 其他 > 详细

csu 1530: Gold Rush(贪心)

时间:2015-03-15 22:35:23      阅读:317      评论:0      收藏:0      [点我收藏+]

http://acm.csu.edu.cn/OnlineJudge/showsource.php?id=97234

 

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  //freopen("output.txt","w",stdout);
  long long int a,b;
  long long int  temp;
  int t,n;
  scanf("%d",&t);
  while(t--)
  {
    scanf("%d%lld%lld",&n,&a,&b);
    long long int  ans=1;
    for(int i=0;i<n;i++)
      ans*=2;
    if(b>a) a=b;
    int cnt=0;
    //printf("%lld\n",a);
    if(a==ans)
    {
      printf("0\n");
    }
    else
    {
      //cout<<"ddddddddddddd"<<endl;
      //printf("%lld %lld %lld %d\n",ans,a,temp,cnt);
      while(a>0)
      {
        temp=ans/2;
        ans=temp;
        if(a>=temp)
           a-=temp;
        cnt++;
        //printf("%lld %lld %lld %d\n",ans,a,temp,cnt);
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}

  

 

csu 1530: Gold Rush(贪心)

原文:http://www.cnblogs.com/sola1994/p/4340412.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!