hdu1018

/*
分析:
  公式:
    1、x的位数=(int)log10(x)+1;
 2、斯特林近似公式:n!≈sqrt(2*π*n)*(n/e)^n。
 
 此处有:
 log10(n!)=log10(1)+log10(2)+log10(3)+...+log10(n)

                                                   2012-04-30
*/

 

 

 

#include"stdio.h"
#include"math.h"
int main()
{
	int n;
	double temp;
	int T;

	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		temp=0.5*log10(2*3.1415927*n)+n*log10(n/2.718281828459);
		printf("%d\n",(int)temp+1);
	}
	return 0;
}


 

你可能感兴趣的:(hdu1018)