【HDOJ1018】【大数阶乘位数】【斯特林公式】
2024-08-24 13:26:22
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): 41932 Accepted Submission(s): 20544
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
10
20
Sample Output
7
19
19
题目大意:求阶乘位数,数据很大。
题目分析:斯特林公式 X的阶乘位数==llog10(1)+log10(2)+···+long10(n)取整后加1
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
double sum=1.0;
scanf("%d",&n);
for(double i = ; i <= n ;i++)
{
sum+=log10(i);
}
cout << (long)sum << endl;
}
return ;
}
最新文章
- Java中@Override的作用
- Request 和 Response 原理
- OpenFOAM 学习路线 【转载】
- eclipse安装svn和maven插件以及m2e-extras
- 关联规则-R语言实现
- c++复习一:复数运算的简单实现。
- 关于CStdioFile的使用问题
- maven系列(1)-maven的介绍与安装
- HDU 2435 There is a war (网络流-最小割)
- RabbitMQ (三) 发布/订阅
- 用 EPWA 写一个 图片播放器 PicturePlayer
- 基于netty实现的长连接,心跳机制及重连机制
- python3+pyshark读取wireshark数据包并追踪telnet数据流
- ConcurrentHashMap 源码阅读小结
- ios 关于屏幕旋转和屏幕晃动
- Hibernate与MyBatis的对比
- ios开发之--awakeFromNib和initWithFrame分别什么时候调用
- WordPress 客户端软件列表
- 利用Ogr将Kml转为Shape【1】
- OS考研复习笔记——操作系统的定义、目标、作用和发展的主要动力