中国人看世界杯就好比央视报道美国总统选举# Joke - 肚皮舞运动
a*e
1 楼
为啥下面这个出错,用pow(5,k)就可以呢?多谢!
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
while(n/f>0)
{
c+=n/f;
f*=5;
}
return c;
}
};
Input:1808548329Output:452137080Expected:452137076
Correct one
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
int k=1;
while(n/f>0)
{
c+=n/f;
k++;
f=pow(5,k);
}
return c;
}
};
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
while(n/f>0)
{
c+=n/f;
f*=5;
}
return c;
}
};
Input:1808548329Output:452137080Expected:452137076
Correct one
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
int k=1;
while(n/f>0)
{
c+=n/f;
k++;
f=pow(5,k);
}
return c;
}
};