前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >793. Preimage Size of Factorial Zeroes Function

793. Preimage Size of Factorial Zeroes Function

作者头像
用户1147447
发布2019-05-26 00:42:11
3930
发布2019-05-26 00:42:11
举报
文章被收录于专栏:机器学习入门机器学习入门

LWC 74: 793. Preimage Size of Factorial Zeroes Function

Problem:

Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * … * x, and by convention, 0! = 1.) For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x) = K.

Example 1:

Input: K = 0 Output: 5 Explanation: 0!, 1!, 2!, 3!, and 4! end with K = 0 zeroes.

Example 2:

Input: K = 5 Output: 0 Explanation: There is no x such that x! ends in K = 5 zeroes.

Note:

  • K will be an integer in the range [0, 10^9].

思路: 考虑125!有多少个0?实际上是求1 * 2 * 3 * … * 125 有多少个5。

Java版本:

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018年03月06日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • LWC 74: 793. Preimage Size of Factorial Zeroes Function
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档