FZU 1050 Number lengths (思维题)
2017-03-24 11:10
232 查看
Problem Description
N! (N factorial) can be quite irritating and difficult to compute for large values of N. So instead of calculating N!, I want to know how many digits are in it. (Remember that N! = N * (N - 1) * (N - 2) * ... * 2 * 1)
Input
Each line of the input will have a single integer N on it 0 < N < 1000000 (1 million). Input is terminated by end of file.
Output
For each value of N, print out how many digits are in N!.
Sample Input
13
32000
Sample Output
11
130271
#include <iostream> #include<stdio.h> #include<string.h> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<vector> #include<map> #include<stack> #include<queue> #include<set> #include<cmath> typedef long long ll; using namespace std; int t; int main() { int n; while(~scanf("%d",&n)) { double sum=0; for(int i=1; i<=n; i++) { sum+=(double)log10((double)i); } int b=(int)sum; printf("%d\n",b+1); } }
相关文章推荐
- FZU1050 Number lengths(数论,规律,概念)
- fzu 1050 Number lengths
- fzu 1050 Number lengths
- Number lengths FZU - 1050
- FZU 2191 完美的数字(暴力变思维)
- FZU Number lengths(数学)
- 省赛选拔赛之个人赛(三)FZU 1026 |1050 +HDU 3466【思路题】
- 51nod 1050 循环数组最大子段和(思维)
- 【最短路--思维】hdu2066 一个人的旅行、fzu2261 浪里个浪
- FZU 2193 So Hard (简单的思维题目)
- FZU 2230 2230 翻翻棋(思维水题)
- FZU Number lengths(数学)
- FZU - 1062 洗牌问题 (思维题,找规律)
- FZU 2252 Yu-Gi-Oh!【思维+枚举】
- FZU Number lengths(数学)
- 【最小生成树--思维】fzu 2254 英语考试;
- FZU 2197 最小花费(思维题目)
- FZU Number lengths(数学)
- Fzu 2202 犯罪嫌疑人【逻辑推理思维题】好题!
- FZU-2205 据说题目很水(思维、完全二分图性质避免三元环)