Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 34084    Accepted Submission(s): 16111

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
 

看到这个题就像用java写,结果超时。其实这是一道规律题:

N!的长度=log10(i)【i:2~n】+1;

然后就简单了。

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
double tmp=;
for(int i=;i<=n;i++)
tmp+=log10(i+0.0);
int ans =(int)tmp+;
printf("%d\n",ans);
}
return ;
}

hdu 1018 Big Number 数学结论的更多相关文章

  1. HDU 1018 Big Number 数学题解

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

  2. HDU 1018 Big Number

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

  3. HDU 1018 Big Number (数学题)

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

  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 (阶乘位数)

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

  6. hdu 1018 Big Number (数学题)

    Problem Description Inmany applications very large integers numbers are required. Some of theseappli ...

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

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

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

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

  9. HDU 1018 Big Number 斯特林公式

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

随机推荐

  1. python中常用第三方库记录

    python中有很多很好用的第三方库,现在记录一下这些库以及如何下载 一.virtualenv,这是一个可以将生产环境隔离开的python库,非常好用 在linux下使用pip install vir ...

  2. 一些数据 bandwidth之类

    33ms  2436x1125 full resolution write bandwidth  300MB/s memory bandwidth snapdragon 630 10GB/3   // ...

  3. C++11常用特性的使用经验总结(转载)

    C++11已经出来很久了,网上也早有很多优秀的C++11新特性的总结文章,在编写本博客之前,博主在工作和学习中学到的关于C++11方面的知识,也得益于很多其他网友的总结.本博客文章是在学习的基础上,加 ...

  4. IP地址转换、主机大小端、htonl、ntohl实现

    copy   #include <IOSTREAM> //#include <WINSOCK.H> using std; typedef  uint16; unsigned   ...

  5. DevExpress 小计 GridControl 隔行换行

    摘自: http://www.cnblogs.com/yuerdongni/archive/2012/09/08/2676753.html 1. 如何解决单击记录整行选中的问题 View->Op ...

  6. Java笔记20:迭代器模式

    迭代器模式 所谓Iterator模式,即是Iterator为不同的容器提供一个统一的访问方式.本文以Java中的容器为例,模拟Iterator的原理. 1 定义一个容器Collection接口 pub ...

  7. Java笔记10:Struts2简单Demo

    1 下载struts-2.3.24.1-all.zip并解压缩,位置任意,比如我的位置是D:\Download\Java\struts-2.3.24.1 解压缩D:\Download\Java\str ...

  8. LInux 分割合并文件

    有两种方式, 第一种使用dd命令 第二种使用split dd命令是linux下一个非常有用的磁盘命令.它可以将指定大小的块拷贝成一个文件,并在拷贝的同时执行指定的转换.UNIX已经提供了文件切割功能, ...

  9. windows下mysql中文乱码, 配置解决方法

    内容源自:windows下mysql中文乱码, 配置解决方法 解决方法:打开mysql安装目录,打开my.ini文件(如果只有my-default.ini文件,先将其改名为my.ini!!!) 修改内 ...

  10. 重构wm_concat,采用clob做为存储容器

    --Type CREATE OR REPLACE TYPE zh_concat_im AUTHID CURRENT_USER AS OBJECT ( CURR_STR clob, STATIC FUN ...