HDU1018 Big Number

Source: Internet
Author: User
Tags integer numbers

Big number

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 31681 Accepted Submission (s): 14769

Problem DescriptionIn Many applications very large integers numbers are required. Some of these applications is using keys for secure transmission of data, encryption, etc. In this problem you is given a number, you has to determine the number of digits in the factorial of the number. Inputinput consists of several lines of integer numbers. The first line contains a integer n, which is the number of cases to being tested, followed by n lines, one integer 1≤n≤  107 on all line. Outputthe output contains the number of digits in the factorial of the integers appearing in the input.Sample Input21020 Sample Output719sourceasia 2002, Dhaka (Bengal) test instructions: To find the number of factorial of n in the subject can be violent, positive solution should be used Sterling formula, I heard that the Stirling number can do all about factorial of the large number of operations, as if very good appearance, To learn in depth ... Give the formula LOG10 (n!) directly =1.0/2*LOG10 (2*pi*n) +n*log10 (n/e)
intMain () {intT, N; scanf ("%d", &T);  while(T--) {scanf ("%d", &N); if(n = =1) printf ("1\n"); Elseprintf"%d\n", (int)(0.5*LOG10 (2*pi*n) +n*log10 (n/e) +1)); }    return 0;}

HDU1018 Big Number

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.