大数阶乘
来源:互联网 发布:windows无法访问xp 编辑:程序博客网 时间:2024/05/16 02:19
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26436 Accepted Submission(s): 12031
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
//一个超级强大的公式,斯特林公式 n!=(2*pi*n)^1/2 *(n/e)^n;求大数阶乘
//求位数的时候想到用log10,一个大数运算就是如此简单了
#include<iostream>
#include<cmath>
using namespace std;
const double PI=acos(-1.0);
const double e=exp(1.0);
int main()
{
int n,i,k;
while(cin>>n)
{
for(i=0;i<n;i++)
{
cin>>k;
if(k==1) cout<<k<<endl;
else
cout<<int(0.5*log10(2*PI*k)+k*log10(k/e)+1)<<endl;
}
return 0;
}
}
0 0
- 大数阶乘
- 大数阶乘。
- 大数阶乘
- ~阶乘~大数
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘!!
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 黑马程序员————Ip、Udp、Tcp
- hdu 1799 (循环多少次?)(排列组合公式)
- linux vi命令详解
- MySQL 创建用户权限
- HDU1864_最大报销额【01背包】
- 大数阶乘
- A* 寻路算法
- 编写acad.rx文件自动加载arx文件
- 二分图匹配KM算法 POJ2195
- vim设置
- Codeforces 478D Red-Green Towers dp
- POJ 2769 Reduced ID Numbers 同余定理
- 终端下的文本浏览器w3m
- 什么是显卡?为什么计算机要有显卡?