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,布布扣,bubuko.com

时间: 2024-08-05 11:11:53

UVA - 11986 Save from Radiation的相关文章

UVa 12403 - Save Setu

题目:有两种操作:1.当前数值增加:2.输出当前数值. 分析:简单题.模拟即可. 说明:A+B. #include <iostream> #include <cstdlib> #include <string> using namespace std; string s; int main() { int n,sum,add; while (cin >> n) { sum = 0; while (n --) { cin >> s; if (s[0

UVA 11292 Dragon of Loowater(简单贪心)

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato

uva 11292

A - Dragon of Loowater Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 11292 Appoint description:  System Crawler  (2014-11-26) Description Problem C: The Dragon of Loowater Once upon a time, in the K

UVa 10679 - I Love Strings!!

题目:给你一个目标串,和一些模式串,问每个模式串是否在目标串中出现. 分析:字符串,AC自动机.一开始用KMP算法,TLE了才发现会超时,改用AC自动机: 直接利用AC自动机存储,查询即可,然后按顺序输出: 如果模式串中有重复的,直接利用并查集合并即可,只须判断父节点. 说明:╮(╯▽╰)╭计算复杂度时,数据组数被忽略了:注意初始化. #include <iostream> #include <cstdlib> #include <cstring> #include &

UVA 1341 - Different Digits(数论)

UVA 1341 - Different Digits 题目链接 题意:给定一个正整数n,求一个kn使得kn上用的数字最少,如果相同,则输出值最小的 思路: 首先利用鸽笼原理证明最多需要2个数字去组成 设一个数字k,组成k,kk,kkk,kkkk... %n之后余数必然在0 - (n - 1)之间,所以必然能选出两个余数相等的数字相减为0,这个数字就是由0和k组成的. 因此只要考虑一个数字和两个数字的情况,去bfs,记忆化余数,因为余数重复必然形成周期了 代码: #include <stdio.

UVa 10087 - The Tajmahal of ++Y2k

l and dished out an assist in the Blackhawks' 5-3 win over the Nashville Predators.Shaw said just playing with the Blackhawks was enough motivation for him."Positive, I'm playing in the NHL," Shaw said after Sunday's win. "What can't you be

UVA之11292 Dragon of Loowater

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato

UVa 10599【lis dp,记忆化搜索】

UVa 10599 题意: 给出r*c的网格,其中有些格子里面有垃圾,机器人从左上角移动到右下角,只能向右或向下移动.问机器人能清扫最多多少个含有垃圾的格子,有多少中方案,输出其中一种方案的格子编号.格子编号是从 左上角第一个开始,一行一行的按自然数顺序编.起始行列是第一行第一列.所以例如一个格子的行列号为(ro,co),那么它的编号为bh=(ro-1)*column+co,其中column指这个格子有多少列.(我觉得原题里面有个错误,题目叙述倒数第二行应该是41(6,6)不是41(6,7)).

UVA 322 ships (POJ 1138)

题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=258 http://poj.org/problem?id=1138 题目描写叙述:  Ships  Probably everyone who ever attended school knows the game where two opposing players place