# Peking University 1423 big number Sterling Formula

Source: Internet
Author: User
Tags cmath

The first is the solution to violence. Note that it is not the essence of violence, but relative violence:
F (n) = log10 (1*2*3*4 *...... * N) + 1 = log10 (1) + log10 (2) + log10 (3) + ...... Log10 (n) + 1.
The result is 406 Ms AC
# Include <iostream>
# Include <cmath>
Using namespace STD;

Int main (){
Int N, num, I;
Double result;
For (scanf ("% d", & N); N; -- N ){
Scanf ("% d", & num );
Result = 1;
For (I = 1; I <= num; ++ I)
Result + = log10 (double (I ));
Printf ("% d/N", INT (result ));
}
Return 0;
}

Second:
Stirling theorem: http://baike.baidu.com/view/2019233.htm? Fr = ala0_1

N! = SQRT (2 * π * n) * (n/E) ^ N)
Obtain the formula log10 (N !) = Log10 (SQRT (2 * pI * n) + N * log10 (N/E) + 11
# Include <cstdio>
# Include <cmath>
Const double Pi = ACOs (-1.0), E = exp (1.0 );
Int main ()
{
Int t, n;
Scanf ("% d", & T );
While (t --)
{
Scanf ("% d", & N );
Printf ("% d/N", (INT) (log10 (SQRT (2 * pI * n) + N * log10 (N/E) + 1 );
}
Return 0;
}

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.