【推导】The 16th UESTC Programming Contest Preliminary L - Foxtrot
题意:有n瓶药剂,其中只有一瓶药剂有毒。让你用最少的小白鼠试出哪瓶有毒。你只有一次给任意只小白鼠各喂食任意种类药剂的机会。
m只老鼠就能对应2^m种“生死状态”的组合,给每种状态分配一个种类的药剂,然后给每只老鼠喂食“如果它在这种药剂对应的生死状态下死去”的所有药剂,就可以根据发生的死亡情况,分辨出哪瓶药剂有毒。
比如老鼠数有3只。
000 1
001 2
010 3
100 4
110 5
011 6
101 7
111 8
给一号鼠喂4578
给二号鼠3568
给三号鼠2678。
所以答案为(ceil)log2(n)。
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
int T,n;
int main(){
scanf("%d",&T);
for(;T;--T){
scanf("%d",&n);
if(n==1){
puts("0");
continue;
}
for(int i=1;i<=30;++i){
if((1<<i)>=n){
printf("%d\n",i);
break;
}
}
}
return 0;
}
【推导】The 16th UESTC Programming Contest Preliminary L - Foxtrot的更多相关文章
- 【set】【可持久化Trie】The 16th UESTC Programming Contest Preliminary K - Will the circle be broken
题意:You are given an array A of N non-negative integers and an integer M. Find the number of pair(i,j ...
- 【字符串哈希】The 16th UESTC Programming Contest Preliminary F - Zero One Problem
题意:给你一个零一矩阵,q次询问,每次给你两个长宽相同的子矩阵,问你它们是恰好有一位不同,还是完全相同,还是有多于一位不同. 对每行分别哈希,先一行一行地尝试匹配,如果恰好发现有一行无法对应,再对那一 ...
- The 15th UESTC Programming Contest Preliminary M - Minimum C0st cdoj1557
地址:http://acm.uestc.edu.cn/#/problem/show/1557 题目: Minimum C0st Time Limit: 3000/1000MS (Java/Others ...
- The 15th UESTC Programming Contest Preliminary J - Jermutat1on cdoj1567
地址:http://acm.uestc.edu.cn/#/problem/show/1567 题目: Jermutat1on Time Limit: 3000/1000MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554
地址:http://acm.uestc.edu.cn/#/problem/show/1554 题目: C0ins Time Limit: 3000/1000MS (Java/Others) M ...
- The 15th UESTC Programming Contest Preliminary B - B0n0 Path cdoj1559
地址:http://acm.uestc.edu.cn/#/problem/show/1559 题目: B0n0 Path Time Limit: 1500/500MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary K - Kidd1ng Me? cdoj1565
地址:http://acm.uestc.edu.cn/#/problem/show/1565 题目: Kidd1ng Me? Time Limit: 3000/1000MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary G - GC?(X,Y) cdoj1564
地址:http://acm.uestc.edu.cn/#/problem/show/1564 题目: G - GC?(X,Y) Time Limit: 3000/1000MS (Java/Others ...
- The 15th UESTC Programming Contest Preliminary H - Hesty Str1ng cdoj1551
地址:http://acm.uestc.edu.cn/#/problem/show/1551 题目: Hesty Str1ng Time Limit: 3000/1000MS (Java/Others ...
随机推荐
- Spring4笔记1--Spring概述、IoC
Spring概述: Spring框架: Spring 由 20 多个模块组成,它们可以分为数据访问/集成(Data Access/Integration).Web.面向切面编程(AOP, Aspec ...
- 在linux上安装完oracle数据库后,如何修改ORACLE_HOSTNAME
1.修改HOSTS文件,添加node2到本机IP地址的映射: [root@node2home]# gedit /etc/hosts 最后一行为添加的: 127.0.0.1 localhost loca ...
- 为什么使用do{}while(0)来进行宏定义
最近发现很多代码在进行宏定义的时候使用喜欢使用 #define MACRO_NAME(para) do{macro content}while(0) 的格式,总结了以下几个原因: 1,空的宏定义避 ...
- 2018ICPC南京网络赛
2018ICPC南京网络赛 A. An Olympian Math Problem 题目描述:求\(\sum_{i=1}^{n} i\times i! \%n\) solution \[(n-1) \ ...
- Flask小demo---代码统计系统
功能要求: 管理员登录 # 第一天 班级管理 # 第一天 学生管理 # 第一天 学生登录 上传代码(zip文件和.py文件) 查看个人提交记录列表 highchar统计 学生列表上方使用柱状图展示现班 ...
- 基于gRpc的远程服务框架
作为一个新搭建的软件团队,底层技术尤为重要.为了以后更好的面向不同的项目需求,满足不断变化的需求,决定着手搭建一套RPC系统.为了更好的兼容以后部门其他语言的使用,选择了开源框架gRpc. gRpc ...
- JQ实现情人节表白程序
JQ实现情人节表白页面 效果图: 表白利页,你值得拥有哦! 代码如下,复制即可使用: <!doctype html> <html> <head> <meta ...
- Java 中判断字符串是否为空
public class TestString { public static void main(String[] args) { String abc = null; //先判断是否为null再判 ...
- Oracle学习笔记:实现select top N的方法
由于Oracle不支持select top N语句,所以在Oracle中需要利用order by和rownum的组合来实现select top N的查询. rownum是记录表中数据编号的一个隐藏字段 ...
- JAVA 转义字符串中的特殊字符
package test; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { pu ...