h*z
2 楼
//Java
public class Solution {
public int trailingZeroes(int n) {
int ret = 0;
for(long i=5;n/i>=1;i*=5)
ret +=n/i;
return ret;
}
}
有问题么?
public class Solution {
public int trailingZeroes(int n) {
int ret = 0;
for(long i=5;n/i>=1;i*=5)
ret +=n/i;
return ret;
}
}
有问题么?
g*t
4 楼
// Python
算法看了下攻略,自己实现一个
class Solution:
# @return an integer
def trailingZeroes(self, n):
# the number of zeroes depends on the pair of '2' * '5' . Obviously,
2 is more than 5 in n!. just count how many 5 are multiplied in factorial.
if n <= 0 : return 0
res = 0
size = 0
while n != 0:
size = n / 5
res += size
n = size
return res
算法看了下攻略,自己实现一个
class Solution:
# @return an integer
def trailingZeroes(self, n):
# the number of zeroes depends on the pair of '2' * '5' . Obviously,
2 is more than 5 in n!. just count how many 5 are multiplied in factorial.
if n <= 0 : return 0
res = 0
size = 0
while n != 0:
size = n / 5
res += size
n = size
return res
z*c
8 楼
public int trailingZeroes(int n) {
int count = 0;
while (n > 0) {
count += n/5;
n /= 5;
}
return count;
}
int count = 0;
while (n > 0) {
count += n/5;
n /= 5;
}
return count;
}
相关阅读
大家觉得pure storage怎么样?现在是不是必须进internet公司啊老东家的hr非叫我把假期用掉再不团结,真他娘的要成低等种族了 (转载)rumor说qcom明年还要裁千人以上?招computational linguistics postdoc...为啥技术牛的公司不怎么挣钱Amazon RelocationFB onsite 面经求问 HR如果要reference 必须某个系的为啥LN要建在G旁边?Bloomberg phone interview 面经Facebook drops Bing in favor of its own search toolRocket Fuel Data Platform组你还在考cfa?大数据都“占领华尔街了”!refer eBay SDE 以及其他职位 针对新毕业生和想换工作的同学broadcom,irvine,senior staff package的RSU只有25K,是不是可怜了点?觉得100K才像话?谷歌老中真有装逼的大家对SDET或者SET职位有什么看法你们一个月就 光吃饭 (转载)