码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2178 猜数字

时间:2018-08-04 12:03:28      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:tle   sam   scanf   ali   main   代码   include   tar   inpu   

http://acm.hdu.edu.cn/showproblem.php?pid=2178

 

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
 
代码:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int T;
    scanf("%d", &T);
    while(T --) {
        int x;
        scanf("%d", &x);
        int num = pow(2, x) - 1;
        printf("%d\n", num);
    }
    return 0;
}

  

HDU 2178 猜数字

标签:tle   sam   scanf   ali   main   代码   include   tar   inpu   

原文地址:https://www.cnblogs.com/zlrrrr/p/9417369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!