題意:A有1數m,B來猜.B每猜一次,就說太大,太小或對了。問B猜n次可以猜到的最大數。
思路:猜n次,你能猜到的最大數的數爲2^n-1.我們也可認爲,在數1到2^n-1間,我們都可以在n次內猜出來。
感想:也許這個題也能用二分,但是我想不出來。
代碼:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int
n,t;
while(scanf("%d",&t)!=EOF)
{
while(t--&&scanf("%d",&n))
{
printf("%d\n",(int)pow(2,n)-1);
}
}
return
0;
}