题意:有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的更多相关文章

  1. 【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 ...

  2. 【字符串哈希】The 16th UESTC Programming Contest Preliminary F - Zero One Problem

    题意:给你一个零一矩阵,q次询问,每次给你两个长宽相同的子矩阵,问你它们是恰好有一位不同,还是完全相同,还是有多于一位不同. 对每行分别哈希,先一行一行地尝试匹配,如果恰好发现有一行无法对应,再对那一 ...

  3. 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 ...

  4. The 15th UESTC Programming Contest Preliminary J - Jermutat1on cdoj1567

    地址:http://acm.uestc.edu.cn/#/problem/show/1567 题目: Jermutat1on Time Limit: 3000/1000MS (Java/Others) ...

  5. 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 ...

  6. 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)    ...

  7. 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) ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. XXX变种-防火墙放行自身

    1.利用防火墙命令放行自身手法 netsh firewall add allowedprogram "C:\Users\USER\AppData\Local\Temp\Discord Can ...

  2. 关于Java中final关键字的详细介绍

    Java中的final关键字非常重要,它可以应用于类.方法以及变量.这篇文章中我将带你看看什么是final关键字?将变量,方法和类声明为final代表了什么?使用final的好处是什么?最后也有一些使 ...

  3. jQuery-选择器-查找标签

    一.jQuery选择器 jQuery选择器就是帮助我们快速定位到一个或多个DOM节点 1.1  ID选择器 如果某个DOM节点有id属性,利用jQuery查找方式: <script src=&q ...

  4. java基础24 线程、多线程及线程的生命周期(Thread)

    1.1.进程 正在执行的程序称作为一个进程.进程负责了内存空间的划分 疑问1:windows电脑称之为多任务的操作系统,那么Windows是同时运行多个应用程序呢? 从宏观的角度:windows确实在 ...

  5. Unix IPC之FIFO

    #include "unpipc.h" #define FIFO1 "/tmp/fifo.1" #define FIFO2 "/tmp/fifo.2& ...

  6. SQLServer判断指定列的默认值是否存在,并修改默认值

    SQLServer判断指定列的默认值是否存在,并修改默认值 2008年10月21日 星期二 下午 12:08 if exists(select A.name as DefaultName,B.name ...

  7. 大家来探讨下,IRepository 应该怎么定义?

    ORM已EF为例子:我见的最多的是泛型的IRepository, public partial interface IRepository<T> where T : BaseEntity{ ...

  8. **PHP删除数组中特定元素的两种方法array_splice()和unset()

    方法一: 复制代码代码如下: <?php$arr1 = array(1,3, 5,7,8);$key = array_search(3, $arr1); if ($key !== false)  ...

  9. Asp.net Vnext 调试源码

    概述 本文已经同步到<Asp.net Vnext 系列教程 >中] 如果想对 vnext深入了解,就目前为止太该只有调试源码了 实现 github上下载源码 选择对应的版本,版本错了是不行 ...

  10. php中直接执行mysqli_init()也是报Property access is not allowed yet的错误。

    xdebug.auto_trace = On 和 xdebug.profiler_enable = On注释掉就OK了,不知道这两个配置项是干嘛的