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

这个程序需要改进,否则wa,下面这样就过了:)

Posted by watt at 2007-03-17 17:31:21 on Problem 1423
In Reply To:Re:什么是“有问题”?什么是“真正”?Stirling公式本来就是用~而不是用=的 Posted by:fzk at 2005-07-24 11:07:21
#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 cas, ans;
	double i, 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 );
		ans = (int)s;
		if( ans <= s )
			ans++;
		
		printf( "%d\n", ans );
	}

	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