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 |
此题要过的话我想只能用Stirling公式了利用Stirling公式 n! = √2πn (n/e)^n (1+Θ( 1/n)) 取n! ≈sqrt(2*pi*n)*(n/e)^n; 对n! 取10的对数log10; 得log10(n!) = log10(sqrt(2*π*n)) + n * log10(n/e); e = 2.7182818284590452354 pi = 3.141592653589793239 当 a > 100000时。使用下面的函数求解 double f( int a ) { return log10( sqrt( 2 * pi * a ) ) + a * log10( a / e ); } 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) + 1 ); Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator