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#中关于公共类的使用
    关于SQL中Between语句查询日期的问题
    用户控件 与 重写控件 的区别
    什么是命名空间,为什么要使用命名空间?
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2753109.html
Copyright © 2011-2022 走看看