Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

hdu 2178 (数学题)

$
0
0

点击打开链接


在最坏的情况下,在1到m间,你最多只要猜log2(m)+1(取整)次,所以易知==>m=2^n-1.即猜n次,你能猜到的最大数的数为2^n-1.我们也可认为,在数1到2^n-1间,我们都可以在n次内猜出来。


#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#include"math.h"
#include"queue"
#define N 31
typedef __int64 int64;
using namespace std;
int main()
{
	int T;
	int n;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		printf("%d\n",(int)pow(2,n)-1);
	}
	return 0;
}

	


作者:yyf573462811 发表于2013-4-20 10:06:38 原文链接
阅读:51 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>