hdu 1018 计算一个数阶乘的位数
来源:互联网 发布:远程桌面数据加密错误 编辑:程序博客网 时间:2024/05/02 02:28
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
题意:求一个数的阶乘的位数
因为根据数学知识可以知道:
log10(1*2*3*4.........*n)=log10(1)+log10(2)+log10(3)+log10(4)...........+log10(n);
又因为阶乘很可能超出整形,不容易计算,所以就应用log进行计数
#include<stdio.h>
#include<math.h>
int main()
{
int t,m;
scanf("%d",&t);
while(t--)
{
double sum=0;
scanf("%d",&m);
for(int i=1;i<=m;i++)
sum+=log10(i);
printf("%d\n",((int)sum)+1);
}
return 0;
}
0 0
- hdu 1018 计算一个数阶乘的位数
- 计算一个数阶乘的位数
- hdu 1018 Big Number (求一个数的阶乘的位数,公式!!!)
- hdu(1018)Big Number(阶乘位数的计算)
- HDU--1018--Big number!(计算阶乘结果的位数)
- HDU 1018 Big Number(阶乘位数计算)
- 求一个数阶乘的位数
- 求一个数阶乘的位数
- 计算一个数的位数
- 阶乘位数的计算
- hdu 1018阶乘位数
- HDU 1018 阶乘的位数 stirling公式
- HDU 1018 求阶乘的位数
- 求一个数的阶乘的结果的位数
- 求一个数阶乘的位数&N^N的位数(数学)
- hdu 1018 -Big Number(求n的阶乘的位数)
- 计算阶乘的位数 poj 1423
- POJ 1423 计算阶乘的位数
- 关于java的视频资料分享
- 窗口抖动
- MakeFile基础知识(七)
- android实现下拉刷新上拉加载更多理解
- HDU1224 Free DIY Tour 【SPFA】
- hdu 1018 计算一个数阶乘的位数
- 理解别人的想法,感受他情绪的变化,水至清则无鱼
- cocos2d-x中各种动作和特效的详细解释
- Java 从网络上下载文件
- 2030年后的《异类》: 中国人口年龄构成统计 2007 - 2100
- 中国每年出生人口数 1976年 - 2000年 历年男女性别比
- linux gpio模拟i2c的使用/用GPIO模拟I2C总线-1 .
- OC_内存管理的原则
- 如何确定抽样统计的最小样本量(附:随机抽样统计的抽样误差Excel计算表格)