POJ上有这个题目。http://poj.org/problem?id=1401。去掉一大堆没有用的信息,POJ的描述如下:
For example, they defined the function Z. For any positive integer N, Z(N) is the number of zeros at the end of the decimal form of number N!. They noticed that this function never decreases. If we have two numbers N1 < N2, then Z(N1) <= Z(N2). It is because we can never "lose" any trailing zero by multiplying by any positive number. We can only get new and new zeros. The function Z is very interesting, so we need a computer program that can determine its value efficiently.
大概意思就是求N!的末尾0的个数。比如:5! = 120;则末尾0的个数为1.
呵呵,这个题目还不简单么。看初中生的解法:

博客讲述了如何计算阶乘N!末尾0的个数,从初中的简单方法到考虑溢出问题,再到使用高精度模拟和大学生解法的优化过程。博主通过不断改进算法,最终得出一个高效且适用于大数阶乘的解决方案,该算法具有较低的时间复杂度。
最低0.47元/天 解锁文章
2028

被折叠的 条评论
为什么被折叠?



