Hdu 2178 猜数字
2015-02-26 15:25
232 查看
猜数字
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行是整数T,表示有T组数据,以下有T行
每行一个整数n (1 ≤ n ≤ 30)
Output
猜n次能够猜到的最大数
Sample Input
2 1 3
Sample Output
1 7
求猜n次最大能猜到的数字,感觉像一种二分的思想,一个数字你要猜到它,最少猜log2(m)+1次就够了,所以在n次之内能猜到的最大数,就是2^n-1
#include <iostream> #include <stdio.h> #include <string> #include <cstring> #include <cmath> #include <algorithm> #define N 100 using namespace std; int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",(int)pow(2,n)-1); } return 0; }
相关文章推荐
- HDU 2178 猜数字
- hdu 2178 猜数字
- hdu 2178 猜数字
- hdu 2178 猜数字
- HDU 2178 猜数字(二分)
- hdu 2178 猜数字(复杂度计算)
- HDU 2178 猜数字(二分思想)
- HDU 2178 猜数字
- Hdu 2178 猜数字
- HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)
- HDU 2178 猜数字 数学题
- HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)
- HDU 2178 猜数字(水题,数学题)
- hdu 2178 猜数字
- Problem H:猜数字(HDU 2178)
- HDU 2178 猜数字
- 求n!最右端非 0的数字!!hdu Last non-zero Digit in N!
- hdu 4333 Revolving Digits循环移动数字找出比原来数大,等于,小的个数。
- hdu 2178
- HDU 1060 求N ^ N 的第一位数字 用log 降低位数