HDU 2178 猜数字

题解:设猜到的最大的数是h,在1到h间,你最多只要猜log2(h)+1(取整)次,
所以易知==>h=2^m-1.即猜m次,能猜到的最大的数为2^m-1。

#include <cstdio>
#include <cmath>
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n;
        scanf("%d",&n);
        printf ("%d\n",(int )pow(2.0,n)-1);
    }
    return 0;
}

 

 

posted @ 2014-02-09 08:50  forever97  阅读(164)  评论(0编辑  收藏  举报