Factorial Trailing Zeroes
2015-06-11 10:57
393 查看
class Solution { public: int trailingZeroes(int n) { int ans=0; while(n) { ans+=n/5; n/=5; } return ans; } };
View Code
阶乘分解质因数,n/5表示[1,n]中有多少是5的倍数,再计算25的倍数 ,125的倍数.....
相关文章推荐
- 【Leetcode Database】Delete Duplicate Emails
- Mail发送外部邮件
- Fair Scheduler中的Delay Schedule分析
- async & await 的前世今生
- 强人工智能:抑制神经元的意义
- K smallest in array with detail explanation
- rails日记1
- http://blog.csdn.net/ya2dan/article/details/7395458
- 创建四个控制器(Main)
- Fibonacci Again
- Training:计算几何基础
- hdoj 1702 ACboy needs your help again!【数组模拟+STL实现】
- ubuntu14.04 安装PIL库出现OError: decoder jpeg not available 的解决方案
- postfix收发邮件大小和webmail空间大小设定
- Training:母函数
- sendmai和dovecot的简单邮件服务器
- Training:筛选法与预处理
- Contains Duplicate II
- 回收子进程函数waitpid详解
- HDU 1532Drainage Ditches(最大流模板题 ISAP)