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 Input21020 Sample Output719 The topic meaning is to give you a number, to find out how many of the number of factorial. Here need to use a logarithmic knowledge of 1. The logarithm of a number for 10 is the number of digits 2. LOG10 (x*y) =log (x) +log (y) know the above two, the topic is quite simple. The code is as follows
1#include <cstdio>2#include <cmath>3#include <cstring>4#include <iostream>5 using namespacestd;6 intN;7 intMain () {8scanf"%d",&n);9 while(n--)Ten { One intT; Ascanf"%d",&t); - intans=0; - Doublek=0; the for(intI=1; i<=t;++i) - { -k+=log10 (i); - } +Ans= (int) K +1; -printf"%d\n", ans); + } A return 0; at}
HDU 1018 Big number math problem