解析:
2次幂问题
每猜一次范围减半所以底数是2
在1到m间,最多log2(m)+1(取整)次,
(m为1时log2(m)=0,最少要猜一次,所以要加1)
所以→m=2n-1.
所以→猜n次能猜到的最大数的数为2n-1.
即在数1到2n-1间,都可以在n次内猜出来.
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2178
#include <stdio.h>
#include <math.h>
int main(void)
{
int n;
scanf("%d",&n);
while(n--)
{
int t;
scanf("%d",&t);
printf("%d\n",(int)pow(2,t)-1);
}
return 0;
}