import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @param m int整型
* @return int整型
*/
public int trailingZeroes (int n, int m) {
// write code here
int index1 = 0;
int index2 = m;
while (n % 5 == 0 || n % 2 == 0) {
if (n % 5 == 0) {
index1++;
n = n / 5;
} else {
index2++;
n = n / 2;
}
}
return Math.min(index1, index2);
}
}
本题主要考察数学知识,所用编程语言是java。
只需要统计n*2的m次方中2的因子个数和5的因子个数,返回两者的最小值

京公网安备 11010502036488号