Topic Meaning:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1003
How many 0 are behind the factorial of n?
the factorial of 6 = 1*2*3*4*5*6 = 720,720 is followed by a 0. Input
A number n (1 <= n <= 10^9)
Output
Number of outputs 0
Input Example
5
Output Example
1 Topic Analysis: for the subject, only need to know in n! , if a multiple of 5 is included, the end is one more 0, if it contains 5^2, add 2 0 at the end, and if it contains 5^k, the end adds K 0./** * Factorial after the number of 0, if n! Contains a 5, there is a 0 * has a 5 contains a 0, containing 5^2 2 0, in turn, such as 15%5==0, even if it contains 5 */#include <iostream> #include <cstdio># Include<algorithm>using namespace Std;int Main () { int a[13];a[0]=5; for (int i=1;i<13;i++) { a[i]=a[i-1]*5; } cout<<a[12]<<endl; int n; while (cin>>n) { int cnt=0; for (int k=0;k<13;k++) {for (int i=a[k];i<=n;i+=a[k]) { cnt++; } } cout<<cnt<<endl; } return 0;}
51nod 1003 factorial after 0 of the number