UVA - 11986 Save from Radiation
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的更多相关文章
- uva 11986
假设有n只老鼠 每只老鼠有两种状态 死或活 则n只老鼠有 2^n方种状态 所以n只老鼠可以确定2^n只瓶子 #include <cstdio> #include <cstdlib&g ...
- uva 10894 - Save Hridoy
#include <iostream> #include <string> #include <cstring> #include <cmath> us ...
- UVa 12403 - Save Setu
题目:有两种操作:1.当前数值添加.2.输出当前数值. 分析:简单题.模拟就可以. 说明:A+B. #include <iostream> #include <cstdlib> ...
- UVA 1291 十四 Dance Dance Revolution
Dance Dance Revolution Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Su ...
- UVA 322 ships (POJ 1138)
题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- UVA它11292 - Dragon of Loowater
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA 257 - Palinwords(弦HASH)
UVA 257 - Palinwords 题目链接 题意:输出一个文本里面的palinword,palinword的定义为.包括两个不同的回文子串,而且要求回文子串不能互相包括 思路:对于每一个单词推 ...
- UVA 11292 Dragon of Loowater(简单贪心)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA 1341 - Different Digits(数论)
UVA 1341 - Different Digits 题目链接 题意:给定一个正整数n.求一个kn使得kn上用的数字最少.假设同样,则输出值最小的 思路: 首先利用鸽笼原理证明最多须要2个数字去组成 ...
随机推荐
- webclient下载文件 带进度条
private void button1_Click(object sender, EventArgs e) { doDownload(textBox1.Text.Trim()); } private ...
- 【POJ】The Suspects(裸并查集)
并查集的模板题,为了避免麻烦,合并的时候根节点大的合并到小的结点. #include<cstdio> #include<algorithm> using namespace s ...
- bash构造tmux显示tmux ssh状态
要求: 于tmux内部链接ssh什么时候, 假设有多个ssh主机. 我们要显示相应的主机ip要显示筛查 实现效果 编辑你的bashrc, 由于我习惯在root下操作, 所以/root/.bashrc. ...
- 【java基础】==与equals()方法比较
1.八种基本类型 只有"=="方法进行判断是否相等,比较的是基本数据类型的值,没有equals()方法 2.Java类库中的类 "=="比较的是对象的句柄,即内 ...
- 深入研究Java类载入机制
深入研究Java类载入机制 类载入是Java程序运行的第一步,研究类的载入有助于了解JVM运行过程,并指导开发人员採取更有效的措施配合程序运行. 研究类载入机制的第二个目的是让程序能动态的控制类载 ...
- MEMO:UIButton 中的图片和标题 左对齐
UIButton setImage 和 setTitle之后.默认 image和title 对齐居中, 因为 title 长度不固定. 所以假设要几个这样有image有title的button纵向排列 ...
- HDU 4832(DP+计数问题)
HDU 4832 Chess 思路:把行列的情况分别dp求出来,然后枚举行用几行,竖用几行.然后相乘累加起来就是答案 代码: #include <stdio.h> #include < ...
- Cocos2d-x 3.2 大富翁游戏项目开发-第八部分 角色的散步路径
获得所述路径之后.我们将能够使根据的步行路径的作用,当您点击gobutton什么时候.我们呼吁player的startGo()办法.传入的参数是保存路径2一维数组 void GameBaseScene ...
- Mina框架与Spring整合配置文件
Mina框架与Spring的整合事实上非常easy,主要是要弄清楚要注入的属性的名称,进而选择合适的注入方法. 关于Spring的四种注入方法请还有一篇文章:spring依赖注入的四种方式 <? ...
- Team Foundation Server 2015使用教程--默认团队成员连接tfs及checkin操作