hdu_1018_Big Number_求阶乘长度模板题
来源:互联网 发布:报价单自动生成软件 编辑:程序博客网 时间:2024/05/08 12:10
阶乘长度模板!!
http://acm.hdu.edu.cn/showproblem.php?pid=1018
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12440 Accepted Submission(s): 5558
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
21020
Sample Output
719
- #include<iostream>
- #include <cmath>
- using namespace std;
- int normal(double n)
- {
- double x=0;
- while(n)
- {
- x +=log10(n);
- n--;
- }
- return (int)x+1;
- }
- long stirling(double n)
- {
- long x=0;
- if( n ==1 )
- x = 1;
- else
- {
- x = (long)( (log10(sqrt(4.0*acos(0.0)*n)) + n*(log10(n)-log10(exp(1.0)))) + 1 );
- }
- return x;
- }
- int main()
- {
- int n;
- cin>>n;
- while(n--)
- {
- int x;
- cin>>x;
- cout<<stirling(x)<<endl;
- }
- return 0;
- }
- hdu_1018_Big Number_求阶乘长度模板题
- 求阶乘的模板
- 求阶乘模板
- 求N阶乘的长度
- 斯特林近似求N阶乘的长度
- NYoj 69 数的长度(求阶乘长度)
- 模板元编程:求N的阶乘
- 51NOD 求n的阶乘的长度(斯特林公式)
- 求n的阶乘的长度 斯特林共识
- 使用模板函数求数据类型长度
- java50题----22求阶乘
- 两个模板元编程求阶乘的例子
- 求阶乘
- 求阶乘
- 求阶乘
- 求阶乘
- 求阶乘
- 求阶乘
- Windows下emacs-w3m设置代理
- AS3之NetStatusEvent参考,视频播放
- 教你如何正确地在ATM上取钱
- Android 字体大小怎么自适应不同分辨率?
- GPIO驱动分析 & GPIO使用方法--S5PC110和S5PC210
- hdu_1018_Big Number_求阶乘长度模板题
- 点评2008年九大经济学家惊人语录
- Eclipse 3.4使用dropins的插件安装方式
- Android 怎么退出整个应用程序?
- Des密码 C++实现
- java运行jar包中指定Class的main方法
- http://poj.org/problem?id=1975&&同上
- jQuery实现HTML表格隔行变色及鼠标悬停变色效果
- vim 正则表达式之环视