Poj 1423 big number (mathematical formula)

Source: Internet
Author: User

 

Description

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 <= m <= 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

21020

Sample output

719
// The formula must be used for this question. The data size is too large. // Stirling formula: n! = (2 * pI * n) ^ (1/2) * (n/E) ^ N); premise: n> 3 // lg (N!) can be exported !) = (Lg (2 * PI) + lg (N)/2 + N * (lg (N)-lg (e )); # include <iostream> # include <cmath> using namespace STD; int main () {int test, N; long int s; const long double C1 = 0.798179868358; // lg (2 * PI) const long double C2 = 0.434294481903; // lg (e) Long Double C3; CIN> test; while (-- Test + 1) {CIN> N; C3 = log10 (double) n); S = 1; if (n> 3) {S = (C3 + C1) /2 + N * (C3-C2) + 1; cout <S <Endl;} elsecout <1 <Endl;} return 0 ;}

 

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.