csu 1530: Gold Rush(贪心)

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;
}

  

时间: 2024-12-20 17:08:43

csu 1530: Gold Rush(贪心)的相关文章

Gold Rush(hnu13249)

Gold Rush Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB Total submit users: 15, Accepted users: 10 Problem 13249 : No special judgement Problem description Alice and Bob are on an adventure trip. Deep in the woods they discover

poj3623 Best Cow Line, Gold(贪心)

题目链接: huangjing 思路: 选取字典序最小的串,那么值得考虑的是当两端出现相等时,继续比较,直到出现不同的结果.. 题目: Best Cow Line, Gold Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4574   Accepted: 1682 Description FJ is about to take his N (1 ≤ N ≤ 30,000) cows to the annual"Farme

GCPC2014 G Gold Rush

题意:有一块2^n大的金块,你每一次只能把一块变成相同的两快(当然大小是原来的1/2),问你现在有容量a,b,a+b = 2^n的背包,多少次能够使得a,b把这所有的金块都装下去. 解题思路:递归. 解题代码: 1 // File Name: f.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月15日 星期日 12时19分58秒 4 5 #include<vector> 6 #include<list> 7 #includ

吐血推荐250部必看电影下载 IMDB TOP 250 download

中文名: IMDB Top 250合辑 TLF-MiniSD收藏版英文名: IMDB Top 250 TLF-MiniSD Collection版本: (更新至TOP119)[MiniSD]发行日期: 2010年地区: 美国语言: 英语 简介: IMDB Top 250合辑 TLF-MiniSD收藏版制作&发行:TLF HALFCD TeamTLF耗时2年精心打造,虎年开篇扛鼎之作 IMDB TOP 250邀您共赏一个世纪的经典 IMDB TOP250是IMDB网站里很受欢迎的特色栏目,里面列出

10 Best TV Series Based On Hacking And Technology

Technology is rapidly becoming the key point in human lives. Here we have discussed top TV shows which have hacking as the central theme. 10 Best TV Series Based On Hacking And Technology Well, if you are a tech fanatic then you will love watching TV

全球100部最佳影片排行

全球100部最佳影片排行 以下是IMDB(美国著名影评网站)网民评出全球100部最佳影片 :  1. <教父>The Godfather 1972年 8.9 分  科波拉黑帮经典<教父>的首部,派拉蒙公司最成功的影片之一,坐稳IMDB头把交椅应属,众望所归.虽然评论界一致对<教父>系列的第2集推崇有佳,但大多数影迷似乎还是对<教父>情有独钟,这可能与马龙·白兰度极具个力的表演有关,直到今天他那种含 糊沙哑的声音与神秘莫测的表情都依然叫人着迷.  2. <

BBC票选出的100部最经典美国电影,你看过几部?

BBC票选出的100部最经典美国电影,你看过几部? 导读:BBC票选出的100部最经典美国电影,你看过几部? 2015-07-27欧美内参欧美内参欧美内参 微信号zoujinoumei 功能介绍<欧美内参>唯一号,国内首个全面解读欧美社会的微媒体,辐射范围遍布全球130多个国家,深刻.独到.精致.有料.犀牛财经联盟发起人之一,蓝鲸财经记者联盟.北平财经公社资深成员.“有一种鸟儿是永远关不住的,它的每一片羽翼上都沾满了自由的光辉.” 点击上面蓝色字关注,即可免费订阅欧美内参. 欧美 1.公民凯恩

Training Neural Networks: Q&amp;A with Ian Goodfellow, Google

Training Neural Networks: Q&A with Ian Goodfellow, Google Neural networks require considerable time and computational firepower to train. Previously, researchers believed that neural networks were costly to train because gradient descent slows down n

The 10 Best Neighborhoods in Seattle

https://www.seattlemet.com/articles/2015/4/24/the-10-best-neighborhoods-in-seattle-may-2015 By Darren Davis  4/24/2015 at 3:00pm  Published in the May 2015 issue of Seattle Met 2413 IMAGE: DOUG CHAYKA THE CONDO CRAZE Capitol Hill 27% own  •  73% rent