Zoj problem set-1526 big number

Source: Internet
Author: User
Tags integer numbers

Time Limit: 10 seconds memory limit: 32768 KB

In specified applications very large integers numbers are required. some of these applications are using keys for secure transmission of data, encryption, etc. in this problem you are given a number, you have to determine the number of digits in the factorial of the number.

Input
Input consists of several lines of integer numbers. the first line contains an integer N, which is the number of cases to be tested, followed by n lines, one integer 1 <= n <= 10 ^ 7 on each line.

Output
The output contains the number of digits in the factorial of the integers appearing in the input.

Sample Input
2
10
20

Sample output
7
19

Source:Asia 2002, Dhaka (Bengal)

When I solve this question, I wonder: what is the difference between floor (double) and (INT) double? The former takes the maximum integer not greater than the specified parameter, and the latter discards the fractional part. Are the two unequal?

 
# Include <iostream>
 
# Include <cmath>
 
# Include <algorithm>
 
Using NamespaceSTD;
 
 
IntMain ()
 
{
 
IntCases, N; CIN> cases;
 
While(Cases -- & CIN> N)
{
 
DoubleDigit = 0;
 
For(IntI = 1; I <= N; I ++)
 
Digit + = Log (I * 1.0 );
Cout <(Int) (Digit/log (10.0) + 1 <Endl;
 
}
 
}// AC

 

 
# Include <iostream>
# Include <cmath>
 
# Include <algorithm>
 
Using NamespaceSTD;
 
 
 
IntMain ()
{
 
IntCases, N; CIN> cases;
 
While(Cases -- & CIN> N)
 
{
 
DoubleDigit = 0;
For(IntI = 1; I <= N; I ++)
 
Digit + = Log (I * 1.0 );
 
Cout <floor (digit/log (10.0) + 1 <Endl;
 
}
}< span style =" color: #008000 "> // wa  

Contact Us

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.