How Many Digits?

Often times it is sufficient to know the rough size of a number, rather than its exact value. For example, a human can reason about which store to visit to buy milk if one store is roughly 11 kilometer away, and another store is roughly 100100 kilometers away. The exact distance to each store is irrelevant to the decision at hand; only the sizes of the numbers matter.

For this problem, determine the ‘size’ of the factorial of an integer. By size, we mean the number of digits required to represent the answer in base-1010.

Input

Input consists of up to 1000010000 integers, one per line. Each is in the range [0,1000000][0,1000000]. Input ends at end of file.

Output

For each integer nn, print the number of digits required to represent n!n! in base-1010.

Sample Input 1 Sample Output 1
0
1
3
10
20
1
1
1
7
19

题意

求n的阶乘的长度

思路

公式https://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E9%9D%88%E5%85%AC%E5%BC%8F

#include<bits/stdc++.h>
using namespace std;
double ans[]={};
int main(){
int n;
for(int i=;i<=;i++){
ans[i]+=ans[i-]+log10(i);
}
while(cin>>n){
cout<<int(ans[n]+)<<endl;
}
}

最新文章

  1. 使用Docker Mysql 5.7
  2. Matlab2015入门学习02
  3. D1.1.利用npm(webpack)构建基本reactJS项目
  4. nginx找不到php文件
  5. FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
  6. css笔记——移动端
  7. UVa12304
  8. KEIl混合编程步骤详解
  9. BC 65 ZYB&#39;s Premutation (线段树+二分搜索)
  10. C++重载运算符的规则
  11. A*算法(八数码问题)
  12. ADO.NET 获取SQL SERVER数据库架构信息
  13. CSS问题
  14. 对配置文件 xml 进行操作
  15. Tomcat出现端口占用错误
  16. J-Link GDB Server Command
  17. HAL无阻塞延时
  18. java http get、post请求
  19. Vim中如何使用正则进行搜索
  20. Objective-C和Swift混合编程开发

热门文章

  1. python编写简单的html登陆页面(1)
  2. 洛谷P3628 [APIO2010]特别行动队 斜率优化
  3. centos7的编译安装php5.3 (针对老系统必须安装php5.3才能运行)
  4. Ubuntu 终端配置
  5. css3 3d  魔方
  6. 训练1-W
  7. HDU6010 Daylight Saving Time
  8. hdu 3177贪心
  9. Oracle的JDBC Url的几种方式
  10. wpf 全局异常捕获处理