题解 | #快速生长的草#
快速生长的草
https://www.nowcoder.com/practice/de1d9ec0d53d4202ae83dc3b25a63166
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @return int整型 */ public int trailingZeroes (int n, int m) { // write code here //由题意,m天后草的数量为n*(2^m); int val = n<<m; int res =0; //统计0的数量 while(val%10==0){ val/=10; res++; } return res; } }
面试高频TOP202 文章被收录于专栏
面试高频TOP202题解