Big Number

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

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
 
题意:求n的阶乘的位数
本题可以暴力,正解应该是用斯特林公式,听说斯特林数能够做一切关于阶乘的大数运算,好像很牛逼的样子,要深入学习。。。直接给出公式
log10(n!)=1.0/2*log10(2*pi*n)+n*log10(n/e)
int main() {
int T, n;
scanf("%d", &T);
while (T --) {
scanf("%d", &n);
if (n == ) printf("1\n");
else printf("%d\n", (int)(0.5*log10(*PI*n)+n*log10(n/e)+));
}
return ;
}

HDU1018 (斯特林公式)的更多相关文章

  1. hdu1018 Big Number 斯特林公式 求N!的位数。

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

  2. 斯特林公式 hdu1018

    杭电上面1018>>点击测试<< 思路:当问到阶乘的值时候,用万进制来写:但是问阶乘值的位数的时候,就可以用斯特林公式了 log10(2*pi*n)/2+n*log10(n/e ...

  3. hdu1018

    可以用斯特林公式直接求出n!的结果. 当n较小时公式已经很准确了,所以可以使用.但是,对于这种极限值为1的公式,只能用来估计位数,不能作为严格的等于的公式.类似的有素数分布定理  x/ln(x)~f( ...

  4. hdu--1018--Big Number(斯特林公式)

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

  5. poj 1423 打表/斯特林公式

    对于n位数的计算,我们可以采用(int)log10(n) + 1的方法得到n的位数 第一种方法: 对于n!位数的计算,log10(n!) = log10(1) + log10(2) + ... + l ...

  6. hdu1018 Big Number---N!的位数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1018 题目大意: 求n阶乘的位数思路: N的阶乖的位数等于LOG10(N!)=LOG10(1)+.. ...

  7. 斯特林公式 ——Stirling公式(取N阶乘近似值)(转)

    斯特灵公式是一条用来取n阶乘近似值的数学公式.一般来说,当n很大的时候,n阶乘的计算量十分大,所以斯特灵公式十分好用.从图中可以看出,即使在n很小的时候,斯特灵公式的取值已经十分准确. 公式为:    ...

  8. 【HDOJ1018】【大数阶乘位数】【斯特林公式】

    http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others)     ...

  9. Nowcoder OI赛制测试2 F 假的数学题 - 斯特林公式 + 二分

    Description 给定$X$, 找到最小的$N$ 使得$N! > X^X$ 数据范围:  $x <= 1e11$ Solution $X^X$ 太大, 高精也存不过, 所以取对数 : ...

随机推荐

  1. python中socket、socketio、flask-socketio、WebSocket的区别与联系

    socket.socketio.flask-socketio.WebSocket的区别与联系 socket 是通信的基础,并不是一个协议,Socket是应用层与TCP/IP协议族通信的中间软件抽象层, ...

  2. LeetCode - 35. Search Insert Position(48ms)

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  3. Spring MVC自动为对象注入枚举数据

    一.实现转换工厂,定义转换实现,如下:     package com.mafwo; import org.springframework.core.convert.converter.Convert ...

  4. Week7 Teamework from Z.XML-任务分配

    任务分配 Z.XML任务初步分配新鲜出炉,请关注! 初步估计,我们的项目需要191小时.但是根据敏捷开发的方法,我们将在开发过程中根据情况迅速调整任务分配,以适应当时问题.

  5. C语言分支/顺序作业总结

    总结 1.1 基本要求(1分) 按时交 - 有分 未交 - 0分 迟交一周以上 - 倒扣本次作业分数 抄袭 - 0分 博客作业格式不规范,没有用Markdown语法 -扣分 泛泛而谈(最多七分) 1. ...

  6. sping事务的理解

    阅读数:2020 一.事务的基本原理 Spring事务的本质其实就是数据库对事务的支持,没有数据库的事务支持,spring是无法提供事务功能的.对于纯JDBC操作数据库,想要用到事务,可以按照以下步骤 ...

  7. user32的使用

    通过代码查询特定的窗口,并在文本框中输入文字然后单击"OK"按钮 需要查找的Dialog 使用Spy++查看窗口信息 通过代码实现功能 class Program { //defi ...

  8. akka与slf4j导致jvm直接crash的诡异

    流程很简单,创建actorSystem,通过actorSystem获取AkkaQueryServiceRetriever,进而通过传递path获得的Gateway进行通信. 之前在主项目里跑的很稳定, ...

  9. JConsole本地连接失败

    一.问题描述 笔者在使用JDK自带的JConsole小工具连接Myeclipse里面注册的MBean时,报如下错: 二.解决办法 添加JVM运行参数: -Dcom.sun.management.jmx ...

  10. Bash script: report largest InnoDB files

    The following script will report the largest InnoDB tables under the data directory: schema, table & ...