Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:什么是“有问题”?什么是“真正”?Stirling公式本来就是用~而不是用=的

Posted by fzk at 2005-07-24 11:07:21 on Problem 1423
In Reply To:什么是“有问题”?什么是“真正”?Stirling公式本来就是用~而不是用=的 Posted by:frkstyc at 2005-04-22 00:20:31
#include <stdio.h>
#include <math.h>

int n;
const double e = 2.7182818284590452354, pi = 3.141592653589793239;

double f( int a )
{
	return log10( sqrt( 2 * pi * a ) ) + a * log10( a / e );
}

int main()
{
	int i, cas;
	double s;
	
	scanf( "%d", &cas );
	
	while( cas-- )
	{
		scanf( "%d", &n );

		if( n < 100000 )
		{
			for( s=0, i=1; i<=n; i++ )
				s += log10( i );
		}
		else s = f( n );
		
		
		printf( "%d\n", (int)(s+1e-7) );
	}

	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator