HDOJ-1018 Big Number

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=1018

Test instructions: Gives a number n, the number of bits of the factorial of the output n

Khan Σ (° °| | |) ︴
At first, we were prepared to multiply the multiplication of large numbers, but the factorial result of 10000 was nearly 40,000.
The factorial of 10^7 ...

Positive: For a number n the number of bits can be calculated with LOG10 (n) + 1
So for n! The number of digits = log10 (1*2*...* (N-1) *n) +1 = log10 (1) +log10 (2) +: +LOG10 (N-1) +log10 (N) + 1
"Simple Rude

# include <stdio.h># include <math.h>int main () {int T, num;scanf ("%d", &t), while (t--) {scanf ("%d", & num);d ouble len = 0;for (int i = 1; I <= num; i++) {len + = log10 ((double) i);} printf ("%d\n", (int) len + 1);} return 0;}

  

HDOJ-1018 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.