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=,q=;
for(int i=;i<=n;i++)
{
if(a%)
{
p=i;
break;
}
a/=;
}
for(int i=;i<=n;i++)
{
if(b%)
{
q=i;
break;
}
b/=;
}
if(p<q)p=q;
printf("%d\n",n-p); }
return ;
}

最新文章

  1. [MetaHook] Event Hook
  2. firefox访问失败的时间设置错误问题
  3. python 零散记录(二) 序列的相关操作 相加 相乘 改变 复制
  4. Android从网络下载文件
  5. 为什么app都是异步编程
  6. A - Network of Schools - poj 1236(求连通分量)
  7. 云服务和虚拟机的预留 IP 地址
  8. socket(套接字)
  9. PHP - 数学运算
  10. JavaEE:XML解析
  11. sqlserver存储过程中,set rowcount 0是什么意思?
  12. js 计时器小练-20160601
  13. parted分区和挂载及非交互式操作
  14. docker命令汇总
  15. RabbitMQ 适用于云计算集群的远程调用(RPC)
  16. Lucene.Net如何实现搜索结果分类统计功能
  17. 编写CentOS的System V init启动脚本
  18. JS碰撞检测
  19. 六. Python基础(6)--语法
  20. MySQL Binlog解析

热门文章

  1. WPF 右上角带数字的按钮
  2. wpf 导出Excel
  3. 5. ASP.NET MVC 中的Areas【区域】是什么
  4. Git-根据tag创建分支
  5. springboot常用注解
  6. java String 内存模型
  7. javaweb项目中的过滤器的使用
  8. linux下发送报警邮件(mailx)
  9. 将 Microsoft Excel 导入至 MySQL
  10. Selenium3 + Python3自动化测试系列三——控制浏览器操作