Factorial Trailing Zeroes
2015-07-27 19:28
330 查看
Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.
思路:有多少个2与5相乘,就有多少个0,由于2远多于5,就是算有多少个5。
class Solution { public: int trailingZeroes(int n) { int len = 0; while(n >= 5) { len = len + n/5; n = n/5; } return len; } };
相关文章推荐
- hdu-1022 Train Problem I (栈的简单应用)
- HDU-2057 A+B Again
- 绑定远程服务的流程aidl
- HDU 2925 Musical Chairs(约瑟夫环问题)
- Climbing Stairs
- offsetof与container_of宏(个人理解)
- poj3250 Bad Hair Day
- hpu 1022&&nyoj 150 Train Problem I 【栈】
- Container With Most Water
- hdu杭电1002 Train Problem I【栈】
- 杭电1022 Train Problem I
- idea 14 Error: Failed to create a child event loop
- hdu4770Lights Against Dudely 暴力搜索
- hdoj 1789 Doing Homework again
- hdoj-1022-Train Problem I(栈)
- 《配置Naigos nrpe的客户端(LINUX、Windows)》
- Rails Mail发送不成功
- Android调用camera错误setParameters failed深层解析
- hdoj 1003 N!Again
- HDOJ 2674 N!Again(同余定理)