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

 

转载于:https://www.cnblogs.com/yuyixingkong/p/4356535.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值