poj1401
来源:互联网 发布:神经网络算法知乎 编辑:程序博客网 时间:2024/06/05 07:57
这道题的思路是从1到n的数中有几个5的倍数,如果是10、20、30等等这些数,因子中只有一个5,所以算一次。如果是25,50,75等等这些数,因子中有5的平方,所以算两次。依此规律,125,625等等同样可以这样算。不可以从1到n遍历,否则会TLE。
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>int main(){ int n; int t,i,c; int count,tmp; scanf("%d",&t); while(t--) { count=0; scanf("%d",&n); c=5; while(c<=n) { count=count+n/c; c=c*5; } printf("%d\n",count); } return 0;}
0 0
- poj1401
- poj1401
- POJ1401
- poj1401
- poj1401
- poj1401(Factorial)
- poj1401 Factorial
- poj1401--Factorial
- POJ1401-Factorial
- Poj1401 - Factorial
- poj1401——Factorial
- 北大ACM poj1401
- POJ1401解题报告
- poj1401解题报告
- 数论基础(POJ1401)
- POJ1401 数学N!因子分解
- poj1401 阶乘最后的零的个数
- poj1401(计算n!中0的个数)
- Windows 下 Apache HTTP Server 安装、配置以及与 Tomcat 的整合(附图)
- ffplay的快捷键以及选项
- leetcode相关
- android自动完成文本 和 单选按钮
- 色彩转换——RGB & HSI
- poj1401
- UVA 11987 Almost Union-Find(带有删除操作的并查集)
- 位操作 二 移位求二进制
- HTML URL编码,这个是地址栏常看到的知识
- java线程技术7_线程中断
- 用 VC 2008 编写 Windows Service(系统服务) atl 编写系统服务
- Sublime Text 2 设置文件详解
- 张小娴经典语录
- C语言register关键字—最快的关键字