Description

J

Save from Radiation

Most of you are aware of Nuclear Power Plant Explosion at Fukushima after devastating earth quake and tsunami. Many people in Bangladesh were seen to be concerned
with radiation. The message says:

BBC Flash news: Japan Government confirms radiation leak at Fukushima nuclear plants. Asian countries should take necessary precautions. If rain comes, remain indoors first 24 hours. Close doors and windows. Swab neck skin with betadine where thyroid area
is, radiation hits thyroid first. Take extra precautions. Radiation may hit Philippine at around 4 pm today. If it rains today or in the next few days in Hong Kong, do not go under the rain. If you get caught out, use an umbrella or raincoat, even if it is
only a drizzle. Radioactive particles, which may cause burns, alopecia or even cancer, may be in the rain.

Many people suggested many things. We, the programmer society, were not inactive. We uploaded a picture in a very popular social network website, facenote and said, "There are two ways to be safe from radiation. One is the Disky way and another is the Buseen
way." You may get clear idea of those two ways from the picture.

Anyway, after the explosion of Fukushima Nuclear Power Plant a bottle of water was sent to my laboratory for experiment. But my stupid robot assistant kept it with
N identical water bottles of which I can't distinguish the special water bottle which came from Japan. I know that if a rat drinks the water from the special bottle, it will die in the 5th minute. Now, I want to identify the special
bottle. But I do not like rat either. So, I want to buy minimum number of rats. Can you help me to find out the minimum number of rats I need for identifying the special bottle in 5 minutes?

I forgot to tell you that, only one drop of water from a bottle is enough to find out if the water is safe or not. And you may also give waters from several bottles to a single rat. If one of these bottles is the special bottle then the rat will die, otherwise
it will not. And assume that the time to give waters to the rats is negligible, because once you decide the strategy; you may ask the robot assistant to do it. And the robot can do it in no time. And you can also assume that the bottles contain sufficient
amount of waters.

Input

Input starts with an integer T (≤ 3000), denoting the number of test cases.

Each test case starts with a line containing an integer N(0 ≤ N ≤ 1016).

Output

For each case, print the case number and the minimum number of rats required for identifying the special bottle.

Sample Input

Output for Sample Input

1
1
2

Case 1: 1

Case 2: 2

Notes

1.      For case 2, the robot assistant kept the special bottle with 2 identical bottles. So, there are 3 bottles, one of them is the special bottle. The minimum number of rats is 2. Because just give a drop from bottle 1 to the 1st rat and a
drop from bottle 2 to the 2nd rat. If the 1st rat dies, so it's clear that bottle 1 is the special one. If the 2nd rat dies, then the second bottle is the special one. And if none of them dies, then the 3rd bottle
is the special bottle. So, 2 rats are enough. But there are other options, too. Like give the first rat two drops from bottle 1 and 2. And give the second rat a drop from bottle 2. Then the special bottle can also be determined. So, there can be many options,
but you need at least 2 rats.

题意:事实上就是求n个普通液体和一瓶毒液,求最少须要几仅仅老鼠同一时候实验,找出毒液

思路:事实上就是能有几个2组成,不够的也要算

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std; int main() {
int t;
int cas = 1;
long long n, ans;
scanf("%d", &t);
while (t--) {
scanf("%lld", &n);
ans = 0;
while (n) {
ans++;
n /= 2;
}
printf("Case %d: ", cas++);
printf("%lld\n", ans);
}
return 0;
}

UVA - 11986 Save from Radiation的更多相关文章

  1. uva 11986

    假设有n只老鼠 每只老鼠有两种状态 死或活 则n只老鼠有 2^n方种状态 所以n只老鼠可以确定2^n只瓶子 #include <cstdio> #include <cstdlib&g ...

  2. uva 10894 - Save Hridoy

    #include <iostream> #include <string> #include <cstring> #include <cmath> us ...

  3. UVa 12403 - Save Setu

    题目:有两种操作:1.当前数值添加.2.输出当前数值. 分析:简单题.模拟就可以. 说明:A+B. #include <iostream> #include <cstdlib> ...

  4. UVA 1291 十四 Dance Dance Revolution

    Dance Dance Revolution Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Su ...

  5. UVA 322 ships (POJ 1138)

    题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  6. UVA它11292 - Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  7. UVA 257 - Palinwords(弦HASH)

    UVA 257 - Palinwords 题目链接 题意:输出一个文本里面的palinword,palinword的定义为.包括两个不同的回文子串,而且要求回文子串不能互相包括 思路:对于每一个单词推 ...

  8. UVA 11292 Dragon of Loowater(简单贪心)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  9. UVA 1341 - Different Digits(数论)

    UVA 1341 - Different Digits 题目链接 题意:给定一个正整数n.求一个kn使得kn上用的数字最少.假设同样,则输出值最小的 思路: 首先利用鸽笼原理证明最多须要2个数字去组成 ...

随机推荐

  1. Windows 8实例教程系列 - 自定义应用风格

    原文:Windows 8实例教程系列 - 自定义应用风格 在Windows 8 XAML实例教程中,曾经提及过应用风格设计方法以及如何创建可复用样式代码.本篇将深入讨论如何创建自定义Windows8应 ...

  2. 为什么OC语言很难

    作为一个Objective-C的coder,我总能听到一部分人在这门语言上抱怨有很多问题.他们总在想快速学习这门语言来写一个App出来,但他们也总是联想到Objective-C看上去实在太难了或者在想 ...

  3. 开源 java CMS - FreeCMS2.1公布

    项目地址:http://www.freeteam.cn/ FreeCMS商业版V2.1更新功能 1.web页面信息採集:通过简单配置就可以抓取目标网页信息,支持增量式採集.keyword替换.定时採集 ...

  4. MVC—WebAPI(调用、授权)

    ASP.NET MVC—WebAPI(调用.授权)   本系列目录:ASP.NET MVC4入门到精通系列目录汇总 微软有了Webservice和WCF,为什么还要有WebAPI? 用过WCF的人应该 ...

  5. 【转】JAVA Socket用法详解

    一.构造Socket Socket的构造方法有以下几种重载形式: (1)Socket() (2)Socket(InetAddress address, int port)throws UnknownH ...

  6. android tips—NumberPicker,DataPicker,TimePicker样式改动

    在使用NumberPicker.DataPicker,TimePicker这几个控件时,非常easy出现例如以下这个界面 可是我们想要的却是以下图示的结果 改动Application.activity ...

  7. 讲座:html5于canvas疯狂的炮轰实现

    <html> <head> <title>坎农</title> <script src="../js/jscex.jscexRequir ...

  8. POJ 2155 Matrix (D区段树)

    http://poj.org/problem?id=2155 Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 1 ...

  9. asp.net使用post方式action到另一个页面,在另一个页面接受form表单的值!(报错,已解决!)

    原文:asp.net使用post方式action到另一个页面,在另一个页面接受form表单的值!(报错,已解决!) 我想用post的方式把一个页面表单的值,传到另一个页面.当我点击Default.as ...

  10. FTP定时批量下载文件(SHELL脚本及使用方法 ) (转)--good

    #/bin/bash URL="http://192.168.5.100/xxx.php" check() { RESULT=$(curl -s $URL) echo $RESUL ...