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