HDU 1124 Factorial 水题

题意:统计n!后面有几个0,    2肯定够用,只要算n!里有几个5就可以了

View Code
#include<cstdio>
#include<cstring>
int main()
{
    int cas, n;
    scanf("%d", &cas);
    while(cas--)
    {
        scanf("%d", &n);
        int s = 5, ans = 0;
        while(s <= n)
            ans += n/s, s *= 5;
        printf("%d\n", ans);
    }
    return 0;
}

 

posted @ 2012-12-04 22:01  To be an ACMan  Views(159)  Comments(0)    收藏  举报