Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:什么是“有问题”?什么是“真正”?Stirling公式本来就是用~而不是用=的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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator