码迷,mamicode.com
首页 >  
搜索关键字:factorial    ( 445个结果
【LeetCode】Factorial Trailing Zeroes
n久不做题了,之前因为考研,然后又是假期,一直懒得做,今天开始吧Givenanintegern,returnthenumberoftrailingzeroesinn!.Note:Yoursolutionshouldbeinlogarithmictimecomplexity.开始没有看到是阶乘,之后又研究复杂度的问题代码如下:classSolution{ public: inttrailingZ..
分类:其他好文   时间:2015-01-05 07:08:59    阅读次数:139
Factorial Trailing Zeroes (divide and conquer)
QUESTIONGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.FIRST TRYclass Sol...
分类:其他好文   时间:2015-01-03 19:49:18    阅读次数:178
Leetcode: 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相乘的结果,所以,可以在n之前看看有多少个2以及多少个5就行了,又发现2的数量...
分类:其他好文   时间:2015-01-02 22:28:57    阅读次数:213
[leetcode]Factorial Trailing Zeroes
老题,简单题。数5的个数就行了。class Solution {public: int trailingZeroes(int n) { int result = 0; while (n > 0) { result += n / 5; ...
分类:其他好文   时间:2015-01-01 00:11:17    阅读次数:194
Factorial Trailing Zeroes
Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.类似于cc:http://www.cnblogs.com/...
分类:其他好文   时间:2014-12-31 08:40:38    阅读次数:193
[leetcode] Factorial Trailing Zeroes
题目:(Math)Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.题解:首先列几个例子找一找规律。然后发现...
分类:其他好文   时间:2014-12-30 23:26:41    阅读次数:170
HappyLeetcode39:Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 这个是我的代码,但是超时 class Solut...
分类:移动开发   时间:2014-12-30 22:06:15    阅读次数:169
LeetCode Factorial Trailing Zeroes
Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Credits:Special thanks to@tsf...
分类:其他好文   时间:2014-12-30 22:01:42    阅读次数:107
[leetcode]Factorial Trailing Zeroes
问题描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 基本思想 尾0的个数取决于5的个数。 代码: int trailingZeroes(int n) { //...
分类:其他好文   时间:2014-12-30 20:43:23    阅读次数:132
Factorial Trailing Zeroes
Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.只有2 * 5才会产生0只要计算出因子中2和5的个数取小的...
分类:其他好文   时间:2014-12-30 20:27:13    阅读次数:169
445条   上一页 1 ... 36 37 38 39 40 ... 45 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!