当前位置: 代码迷 >> 综合 >> hdu2178猜数字
  详细解决方案

hdu2178猜数字

热度:39   发布时间:2023-11-01 07:49:07.0

猜数字

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7415    Accepted Submission(s): 5059


Problem Description
A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" 。 
问B猜n次可以猜到的最大数。 
 

Input
第1行是整数T,表示有T组数据,下面有T行 
每行一个整数n (1 ≤ n ≤ 30) 
 

Output
猜n次可以猜到的最大数
 

Sample Input
   
2 1 3
 

Sample Output
   
1 7

就是(2^n)-1

#include <bits/stdc++.h> using namespace std; int main() {int t;cin>>t;while(t--){int x;cin>>x;long long y=pow(2,x)-1;cout<<y<<endl;} }


  相关解决方案