hdu-1124(数学问题,求n!的尾零的个数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1124

思路:每五个数1个0,5个5就2个0(不用管2,一定充足)

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
int main(void)
{
    LL n,j;
    int tim,ans,t,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld",&n);
        j=1;tim=0;
        while(j<=n)
        {
            j*=5;tim++;
        }
        ans=0;
        for(i=1;i<tim;i++)
        {
            ans+=n/pow(5,i);
        }
        printf("%d
",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/2018zxy/p/9903589.html