<span style="color: rgb(73, 73, 73); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(222, 242, 230);">A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" 。</span><pre style="white-space: normal; color: rgb(73, 73, 73); font-size: 14px; line-height: 21px; background-color: rgb(222, 242, 230);">问B猜n次可以猜到的最大数。 ,,,,,首先,, 设猜到的最大的数字为h,,猜到最大的数字h,也就是 说,在1到h间的每一个数,你都能在m次内把它猜出来! 所以说在最坏的情况下,在1到h间,你最多只要猜log2(h)+1(取整)次,所以易知==>h=2^m-1.即猜m次, 能猜到的最大的数为2^m-1 (水题啊) #include<stdio.h> #include<math.h> int main(){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); int ans=pow(2,n)-1; printf("%d\n",ans); } return 0; }