标签:des style io color ar os sp java strong
2 1 3
1 7
求猜n次最大能猜到的数字,感觉像一种二分的思想,一个数字你要猜到它,最少猜log2(m)+1次就够了,所以在n次之内能猜到的最大数,就是2^n-1
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#define N 100
using namespace std;
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",(int)pow(2,n)-1);
}
return 0;
}
标签:des style io color ar os sp java strong
原文地址:http://blog.csdn.net/wust_zjx/article/details/41127173