zoukankan      html  css  js  c++  java
  • 杭电_ACM_Big Number

    Problem Description
    In many 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 ≤ 107 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
    View Code
     1 #include <stdio.h>
     2 #include <math.h>
     3 int main()
     4 {
     5     int T, n;
     6     double count, i;
     7     scanf("%d", &T);
     8     while (T--)
     9     {
    10         scanf("%d", &n);
    11         count = 1.0;
    12         for (i = 1; i <= n; i++)
    13         {
    14             count += log(i) / log(10.0);
    15         }
    16         printf("%d\n", (int)count);
    17     }
    18     return 0;
    19 }

    just remember using log, it's the core.

  • 相关阅读:
    小端大端
    位域
    c++ 2.1 编译器何时创建默认构造函数
    python 内置&&递归
    python返回值与局部全局变量
    python file
    python set
    python 字典的函数
    python FileError
    python pickle
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2753109.html
Copyright © 2011-2022 走看看