• 杭电_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.

  • 相关阅读:
    ffmpeg文档03-详细说明
    ffmpeg文档01-命令语法
    ffmpeg文档02-描述/概览
    OpenWrt使用花生壳脚本
    upc 9315 Philosopher’s Walk
    upc 9312 Game Map
    hdu 1251 统计难题
    Trie树简要讲解
    [算法]一次商品交易利益最大化
    [c语言]左移和右移
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2753109.html
Copyright © 2020-2023  润新知