Big Number

原创 2016年05月30日 23:34:05
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

 
Source
Asia 2002, Dhaka (Bengal)
 


Recommend
JGShining
weishu
qu log 
ac
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
   double t;
   double sum;
   int n;
   cin>>n;
   int x;
   int i,j;
   int sum1;
   while(n--)
   {
       sum=0;
       cin>>x;
       for(i=x;i>=1;i--)
        {
            sum=sum+log10(i);
        }
        sum1=int(sum)+1;
        cout<<sum1<<endl;
   }
   return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

HDU 1018 Big Number N!的位数

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total...

hdu1212 Big Number &第六届山东省赛Single Round Math (同余定理,大数取模)

题目链接:Big Number   题目大意:每次输入两个数,第一个是高精度,第二个数小于100000;求 a mod b 根据同余定理: (a+b)% c = (a%c+ b%c)%c ...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

POJ1423 Big Number(数学)

题意: 输出n!的位数 要点: n!的位数=log10(n!)+1 有两种方法: 1.直接用log(n!)=log10(1)+log10(2)+……+log10(n)打表做,把1~1e7的先...

HDU 1018 Big Number (数的阶乘的长度:数学)

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot...

HDU 1212 Big Number 大数取模

Big Number                                        ...

ACM-数论之Big Number——hdu1018

ACM 数论 Big Number hdu1018 斯特林公式

HODJ Big Number(java 阶乘)

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot...

Codeforces 757B Bash's Big Day math, number theory

B. Bash's Big Day time limit per test 2 seconds memory limit per test 512 megabytes ...

杭电OJ——1018 Big number!

Big Number    Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)