Problem Description

Inmany applications very large integers numbers are required. Some of theseapplications are using keys for secure transmission of data, encryption, etc.In this problem you are given a number, you have to determine the number ofdigits in the
factorial of the number.

Input

Inputconsists of several lines of integer numbers. The first line contains aninteger n, which is the number of cases to be tested, followed by n lines, oneinteger 1 ≤ n ≤ 107 on each line.

Output

Theoutput contains the number of digits in the factorial of the integers appearingin the input.

SampleInput

2

10

20

Sample Output

7

19

/**************************************************

//  不能直接算N!,数据规模  1<N<10^7  太大,超出  2^31  的范围,所以取对数函数

//  N = M*10^n   n = log10(N)  log10()  函数在头文件cmath中

984 MS,差点超时

************************************************/

#include <iostream>
#include<cmath>
using namespace std;
int main()
{
double sum;
int T,n;
cin>>T;
while(T--)
{
cin>>n;
sum = 1;
for(int i = 1;i<=n;i++)
sum+=log10(i);
cout<<(int)sum<<endl;
}
return 0;
}

hdu 1018 Big Number (数学题)的更多相关文章

  1. HDU 1018 Big Number

    LINK:HDU 1018 题意:求n!的位数~ 由于n!最后得到的数是十进制,故对于一个十进制数,求其位数可以对该数取其10的对数,最后再加1~ 易知:n!=n*(n-1)*(n-2)*...... ...

  2. HDU 1018 Big Number (数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 解题报告:输入一个n,求n!有多少位. 首先任意一个数 x 的位数 = (int)log10(x ...

  3. hdu 1018:Big Number(水题)

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

  4. hdu 1018 Big Number 数学结论

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

  5. HDU 1018 Big Number【斯特林公式/log10 / N!】

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

  6. HDU 1018 Big Number (log函数求数的位数)

    Problem Description In many applications very large integers numbers are required. Some of these app ...

  7. HDU 1018 Big Number 数学题解

    Problem Description In many applications very large integers numbers are required. Some of these app ...

  8. HDU 1018 Big Number 斯特林公式

    Big Number 题意:算n!的位数. 题解:对于一个数来算位数我们一般都是用while去进行计算,但是n!这个数太大了,我们做不到先算出来在去用while算位数. while(a){ cnt++ ...

  9. HDU 1018 Big Number (阶乘位数)

    题意: 给一个数n,返回该数的阶乘结果是一个多少位(十进制位)的整数. 思路: 用对数log来实现. 举个例子 一个三位数n 满足102 <= n < 103: 那么它的位数w 满足 w ...

随机推荐

  1. Web---JS-返回上一页并刷新代码整理

    返回上一页并刷新在此功能有利于用户的体验,是每一个web开发人员所必备的一项,长话短说,今天介绍实现此功能的一个方法,需要了解的朋友可以参考下: 一:JS 重载页面,本地刷新,返回上一页 代码如下: ...

  2. java spring一个类型split的方法

    /** * Take a String which is a delimited list and convert it to a String array. * <p>A single ...

  3. POJ 3125 Printer Queue

    题目: Description The only printer in the computer science students' union is experiencing an extremel ...

  4. JSP_DAO方式实现数据库查询(MyEclipse10,Tomcat7.0,JDK1.7,)——Java Web练习(四)

    1.项目结构: 2.创建数据库.表.插入记录 create database TestDao; use TestDao; create table student( stuid int, userna ...

  5. Java多线程——Executors和线程池

    线程池的概念与Executors类的应用 1.创建固定大小的线程池 package java_thread; import java.util.concurrent.ExecutorService; ...

  6. 微信开发第6章 通过accesstoken获取用户粉丝列表

    上一章我们讲解到open_id获取用户基本信息,那么open_id哪儿来的呢?就是粉丝列表中可以看到的.本次讲解如何获取粉丝列表. 获取粉丝列表 可以查看文档 http://mp.weixin.qq. ...

  7. window系统上用PHP获取本地物理IP代码

    <?php $res=system("ipconfig -all"); $contents=trim(ob_get_clean()); $contents=str_repla ...

  8. 24小时学通LINUX内核系列

    http://www.cnblogs.com/lihuidashen/category/667475.html

  9. iOS 如何做才安全--逆向工程 - Reveal、IDA、Hopper、https抓包 等

    http://www.cnblogs.com/dahe007/p/5546990.html

  10. hdu2025java字符题

    查找最大元素 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...