Problem DescriptionIn Many applications very large integers numbers are required. Some of these applications is using keys for secure transmission of data, encryption, etc. In this problem you is given a number, you has to determine the number of digits in the factorial of the number.
Inputinput consists of several lines of integer numbers. The first line contains a integer n, which is the number of cases to being tested, followed by n lines, one integer 1≤n≤ 107 on all line.
Outputthe output contains the number of digits in the factorial of the integers appearing in the input.
Sample Input
21020
Sample Output
719
123456=1.23456*10^5;
log10 (123456) =5.09151;
log10 (1.23456*10^5) =log10 (1.23456) +log10 (10^5) =0.09151+5;
Int (log10 (n)) +1 is the number of bits of n   1, x number of digits = (int) log10 (x) +1;
2. Sterling Approximate formula: n!≈sqrt (2*π*n) * (n/e) ^n.
#include <iostream> #include <cmath> #include <cstdio>using namespace Std;int main () {int i,t,n;double Ans;cin>>t;while (t--) {cin>>n;ans=0;for (i=1;i<=n;i++) {ans+=log10 (double (i));} printf ("%d\n", int (ans) +1);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 1018 Big Number (the number of bits that the log function evaluates)