In specified applications very large integers numbers arerequired. some of these applications are using keys for Secure Transmission ofdata, encryption, etc. in this problem you are given a number, you have todetermine the number of digits in the factorial
The number.
Input
Input consists of several lines of integer numbers. the first line contains aninteger N, which is the number of cases to be tested, followed by n lines, oneinteger 1 <= n <= 10 ^ 7 on each line.
Output
The output contains the number of digits in the factorial of the integersappearing in the input.
Sample Input
2
10
20
Sample output
7
19
Question:
Given a number N, N is required! .
Analysis
In general, tooooooooooooold
Therefore, it may be considered as a big number problem. In fact, it can be considered as a big number problem, but generally, the processing of large numbers will exceed the space.
In fact, there is another way to solve this problem. In that case, this would be a question. However, the first time I came into contact with the log function to find the length of the number and the sterling formula, it would be of great significance.
Sterling formula:
In the case of N, the sterling formula will be more accurate. The specific derivation can be seen in Baidu encyclopedia.
Formula for calculating the length of M: The number of digits of M is equal to the integer plus 1.
Len = (INT) log10 (m) + 1
Library Function log
# Include <iostream> # include <math. h> using namespace STD; const Double E = 2.718281828459; const double Pi = 3.1415926535898; int main () {Longlong N, TT; CIN> tt; while (tt> 0) {TT --; CIN> N; Longlong ans = (Longlong) (double) log10 (SQRT (2 * pI * n) + N * log10 (N/E )) + 1; cout <ans <Endl;} return0 ;}