51nod 1003【数学】

思路:
2和5能构成0,然后就是看2和5因子组成个数,然而我们知道,1-n中2的因子数肯定>5的,所以我们只要求一下1-n中5的因子个数就好了。。。

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

typedef long long LL;

//求1-n有x因子的个数,给出一个n;

int main()
{
    int n;
    int ans=0;
    scanf("%d",&n);
    while(n)
    {
        ans+=n/5;
        n/=5;
    }
    printf("%d\n",ans);
}
posted @ 2016-08-31 23:33  see_you_later  阅读(106)  评论(0编辑  收藏  举报