您的位置:首页 > 其它

51nod 1003 阶乘后面0的数量

2017-10-25 21:53 281 查看
n的阶乘后面有多少个0?
6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0。

Input
一个数N(1 <= N <= 10^9)

Output
输出0的数量

Input示例
5

Output示例
1
找n!中2和5的个数取一个min,当然2的肯定比5少


#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int get_5(int x) {
int ret=0;
while(x>=5)ret+=x/5,x/=5;
return ret;
}
int main () {
int n;
scanf("%d",&n);
printf("%d\n",get_5(n));
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: