Gold Rush (hnu13249)

Source: Internet
Author: User

Gold Rush
Time limit: 2000ms, special time limit:5000ms, Memory Limit:65536KB
Total Submit users: Accepted users: 10
problem 13249: No Special Judgement
Problem description

Alice and Bob is on a 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 the cave, but it is still to heavy for one of the 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 if you have a spell that can burst one piece of gold into II equally weighted ones. Spell, the cave would be locked one additional day. "  

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



Input

The input starts with the number T <= the 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

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



Sample Input
32 2 22 1 310 1000 24
Sample Output
127
Problem Source
GCPC 2014

title Link:http://acm.hnu.cn/online/?action=problem&type=show&id=13249&courseid=311 Reprint Please specify the Source: Search & Star Children
#include <stdio.h>#defineLL __int64LL A, b;intMain () {intn,t; scanf ("%d",&u);  while(t--) {scanf ("%d%i64d%i64d",&n,&a,&b); intp=0, q=0;  for(intI=0; i<=n;i++)        {            if(a%2) {p=i;  Break; } A/=2; }         for(intI=0; i<=n;i++)        {            if(b%2) {Q=i;  Break; } b/=2; }        if(P&LT;Q) p=Q; printf ("%d\n", N-Q); }    return 0;}

Gold Rush (hnu13249)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.