您的位置:首页 > 其它

HDU 1124 Factorial

2012-05-31 16:05 495 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1124

求n!末尾有多少个0,2*5出0,所以既求有多少个因子5

View Code

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