杭电1018-Big Number(大数)
2024-08-31 08:15:09
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31165 Accepted Submission(s): 14464
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.
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
还记得那个奇妙的斯塔林公式吗?
直接就是公式了!
#include<cstdio>
#include<cstring>
#include<cmath>
#define pi acos(-1.0)
using namespace std;
int n;
int solve()
{
return (int)((n*log(n)-n+(log(2*pi*n))/2)/log(10))+1;
}
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
scanf("%d",&n);
int t=solve();
printf("%d\n",t);
}
return 0;
}
最新文章
- MYSQL数据库------操作命令笔记
- MSIL Hello World
- 通过sqlserver发送邮件
- mysql存储图片问题
- opencv的学习笔记1
- Python抓取网页中的图片到本地
- CSS从今以后不用发愁
- 《UNIX网络编程》之select IO
- MySQL的truncate table 和source 命令
- 在iOS8下使用CLLocationManager定位服务需要系统授权
- ops
- Time complexity of ArrayList in Java
- Struts2命令空间小结
- 如何使用sourcetree 或 IDEA 自带的git合并代码?
- 我对AOP的理解
- javaweb中的乱码问题(初次接触时写)
- Git使用过程中的问题
- js模板引擎-art-template常用总结
- Linux中 Lua 访问Sql Server的配置方法
- JUC源码1-原子量
热门文章
- 我的spark python 决策树实例
- 【优化算法】遗传算法GA求解混合流水车间调度问题(附C++代码)
- NOIP2012 D2 T2 借教室 线段树 OR 二分法
- Service不完全解析
- Windows系统开发常用类-------------Environment类
- Django学习案例一(blog):一. 创建project、app
- Android-crop:漂亮的图片裁切工具
- Android 解决toolbar标题不显示问题
- linux下使用Android studio启动模拟器时提示 waiting for target device to come online 的问题
- **PCD数据获取:Kinect+OpenNI+PCL对接(代码)