1008猜数字
来源:互联网 发布:mac有什么网游 编辑:程序博客网 时间:2024/06/06 06:38
A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" 。 <br>问B猜n次可以猜到的最大数。 <br>
Input
第1行是整数T,表示有T组数据,下面有T行 <br>每行一个整数n (1 ≤ n ≤ 30) <br>
Output
猜n次可以猜到的最大数<br>
Sample Input
2<br>1<br>3
Sample Output
1<br>7<br>
Author
Zhousc
Source
ECJTU 2008 Summer Contest
题目大意:
猜数字游戏,即有t行数,每次输入一个,若是大了说打,小了说小,猜n次可以猜到的最大数。
解题思路:
猜n次,能猜到的最大数字为pow(2,n)-1。所以从1到pow(2,n)-1,在n次都可以猜出来。
感想:
替补并不难,又是中文的,只需要仔细理解题意,注意细节即可。
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, t;
while (cin>>t&&t!=0)
{
for (int i = 0;i<t;i++)
{
cin >> n;
cout <<(int)(pow(2, n) - 1);
}
}
return 0;
}
0 0
- 1008 猜数字
- 猜数字 1008
- 1008 猜数字
- 1008 猜数字
- 1008—猜数字
- 1008猜数字
- HDU 1008 猜数字
- 1008 猜数字
- acm 2 1008 猜数字
- 练习二 1008 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 网络字节码、本地字节码(大端,小端)
- 自定义圆形ImageView
- POJ 1426 Find The Multiple【BFS】
- Oracle的综合查询练习
- fck配置图片上传(php版)
- 1008猜数字
- 最少硬币问题
- 搭建ES6运行环境
- 《Django By Example》读书笔记 03
- openwrt下载路径
- android自定义loding view(下)
- CSS3 box-flex 属性
- SSH导入jar包
- arm中断与定时器学习笔记