hdu 2178

猜数字

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

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

Author

Zhousc

Source

ECJTU 2008 Summer Contest

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
using namespace std;
int t,n;
int main()
{
      scanf("%d",&t);
      while(t--)
      {
            scanf("%d",&n);
            printf("%d\n",(1<<n)-1);
      }
      return 0;
}

  

时间: 2025-01-05 04:57:08

hdu 2178的相关文章

Hdu 2178 猜数字

猜数字 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3415    Accepted Submission(s): 2458 Problem Description A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" . 问B猜n次可以猜到的最大数. Input 第1

HDU 2178.猜数字【分析能力练习】【读题能力联系】【8月10】

猜数字 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 哎呀妈呀,这题什么意思啊!-----第一感觉 仔细理解理解:比如数据中的3次可以最大猜到7

HDOJ(HDU) 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 这个题目我总感觉题意没说明白,没办法.参考了一下网上的题意. 题意就是: 最多猜n次一定可以猜到1

HDU ACM 2178 猜数字

分析:最坏情况下,在1到m间,最多只要猜log2(m)+1(取整)次,所以=>m=2^n-1.即猜n次,猜到的最大数为2^n-1.也可认为,在数1到2^n-1间,都可以在n次内猜出来. #include<iostream> #include<cmath> using namespace std; int main() { int T,n; scanf("%d",&T); while(T--) { printf("%d\n",(s

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12

hdu 1596 find the safest road (最短路径)

find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6119    Accepted Submission(s): 2178 Problem Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;