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.

  • 相关阅读:
    模仿jquery框架源码 -成熟---选择器
    模仿jquery框架源码---网络
    jquery链式语法
    jquery跟DOM转换
    jquery选择器
    基本jquery
    滚屏加载--无刷新动态加载数据技术的应用
    CenterFactory
    IImage--factory
    redis的使用及方法
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2753109.html
Copyright © 2011-2022 走看看