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.
 
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;
}

最新文章

  1. MYSQL数据库------操作命令笔记
  2. MSIL Hello World
  3. 通过sqlserver发送邮件
  4. mysql存储图片问题
  5. opencv的学习笔记1
  6. Python抓取网页中的图片到本地
  7. CSS从今以后不用发愁
  8. 《UNIX网络编程》之select IO
  9. MySQL的truncate table 和source 命令
  10. 在iOS8下使用CLLocationManager定位服务需要系统授权
  11. ops
  12. Time complexity of ArrayList in Java
  13. Struts2命令空间小结
  14. 如何使用sourcetree 或 IDEA 自带的git合并代码?
  15. 我对AOP的理解
  16. javaweb中的乱码问题(初次接触时写)
  17. Git使用过程中的问题
  18. js模板引擎-art-template常用总结
  19. Linux中 Lua 访问Sql Server的配置方法
  20. JUC源码1-原子量

热门文章

  1. 我的spark python 决策树实例
  2. 【优化算法】遗传算法GA求解混合流水车间调度问题(附C++代码)
  3. NOIP2012 D2 T2 借教室 线段树 OR 二分法
  4. Service不完全解析
  5. Windows系统开发常用类-------------Environment类
  6. Django学习案例一(blog):一. 创建project、app
  7. Android-crop:漂亮的图片裁切工具
  8. Android 解决toolbar标题不显示问题
  9. linux下使用Android studio启动模拟器时提示 waiting for target device to come online 的问题
  10. **PCD数据获取:Kinect+OpenNI+PCL对接(代码)