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 a mysterious deep cave which they enter flutteringly. They find an old console with a giant bar of gold in it. On the bar, there is a number n. Both tried to carry the gold out the cave, but it was still to heavy for one of them.

Suddenly a little fairy appears in the corner of the cave and approaches Alice and Bob: “This gold is heavy. It weights 2n femto-grams (10-15) and n can reach 62.”

Bob answered: “What luck! Alice’s knapsack can carry up to a femto-grams and mine b femto-grams with a + b = 2n.” Alice interjected: “But how can we divide the gold?”

Fairy: “I can help you with a spell that can burst one piece of gold into two equally weighted ones. But for each single spell, the cave will be locked one additional day.”

Alice consults with Bob to use the help of the fairy and take all of the gold. How long will they be trapped if they are clever?

Input

The input starts with the number t <= 1000 of test cases. Then t lines follow, each describing a single test case consisting of three numbers n, a and b with a, b >= 1, a + b = 2n, and 1 <= n <= 62.

Output

Output one line for every test case with the minimal number of days that Alice and Bob are locked in the cave.

Sample Input
3
2 2 2
2 1 3
10 1000 24
Sample Output
1
2
7
Problem Source
GCPC 2014

题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=13249&courseid=311

转载请注明出处:寻找&星空の孩子

#include<stdio.h>
#define LL __int64

LL a,b;
int main()
{
    int n,T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%I64d%I64d",&n,&a,&b);
        int p=0,q=0;
        for(int i=0;i<=n;i++)
        {
            if(a%2)
            {
                p=i;
                break;
            }
            a/=2;
        }
        for(int i=0;i<=n;i++)
        {
            if(b%2)
            {
                q=i;
                break;
            }
            b/=2;
        }
        if(p<q)p=q;
        printf("%d\n",n-p);

    }
    return 0;
}
时间: 2024-12-28 23:51:48

Gold Rush(hnu13249)的相关文章

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

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&qu

吐血推荐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

Dawson City【道森市】

Dawson City Cities usually have a good reason for being where they are, like a nearby port or river. 城市之所以存在于它们所在的地方通常有一个很好的理由,比如附近就是港口或河流. People settle in these places because they are easy to get to and naturally suited to communications and trade