题目大意:中文题。可直接在OJ上看
解题思路:
1)“猜n次,能猜到的最大数字为h”。意思是指,猜n次能把1~h之间的数都猜出来。所以n = log2(h) + 1 (右边的这个数字其实就是由1~h这h个数子所组成的完全二叉树
的高度) ----------->>
h=2^n-1
代码如下:
/*
* 2178_1.cpp
*
* Created on: 2013年8月15日
* Author: Administrator
*/
#include <stdio.h>
#include <math.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int max =int (pow(2,n) - 1);
printf("%d\n",max);
}
}