当前位置:网站首页>K zeros after leetcode factorial function
K zeros after leetcode factorial function
2022-04-23 01:38:00 【Programmed ape no hair loss 2】
f(x) yes x! At the end is 0 The number of . Think about it x! = 1 * 2 * 3 * … * x, And 0! = 1 .
for example , f(3) = 0 , because 3! = 6 There is no 0 ; and f(11) = 2 , because 11!= 39916800 Terminal 2 individual 0 .
Given k, Find out if the return can meet f(x) = k Non-negative integer x The number of .
Example 1:
Input :k = 0
Output :5
explain :0!, 1!, 2!, 3!, and 4! All conform to k = 0 Conditions .
Example 2:
Input :k = 5
Output :0
explain : There is no such match x!, accord with k = 5 Conditions .
Example 3:
Input : k = 3
Output : 5
java Code :
class Solution {
public int preimageSizeFZF(long K) {
long lo = K, hi = 10*K + 1;
while (lo < hi) {
long mi = lo + (hi - lo) / 2;
long zmi = zeta(mi);
if (zmi == K) return 5;
else if (zmi < K) lo = mi + 1;
else hi = mi;
}
return 0;
}
public long zeta(long x) {
if (x == 0) return 0;
return x/5 + zeta(x/5);
}
}
版权声明
本文为[Programmed ape no hair loss 2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230137102080.html
边栏推荐
- Prince saves Princess (DFS)
- Modify array (and search set)
- Summary of commonly used commands of LSF
- Introduction to granularity locking of gbase 8s concurrency control
- 最新流程引擎 flowable 6.7.2 更新说明
- Let's talk about passive safety again. I'll teach you to understand the rating report of China Insurance Research Institute collision test
- 智能手表的下半场,机遇与挑战并存
- 什么是布尔类型?
- Abused "architect"!
- Itextsharp displays Chinese fonts
猜你喜欢

“自虐神器”一夜爆火:用手柄控制自己的脸,代码自取,后果自负

Project manager's thinking mode worth trying: project success equation

Qingyan environment and Shenzhen Stock Exchange listing: annual revenue of 180 million and market value of 4.1 billion

W801/W800-wifi-socket开发(一)-UDP

NR polar code VII - SCL (successful cancellation list coding)

数字藏品平台入驻 数字藏品平台开发 数字藏品SaaS平台

Completely uninstall antidote 10? What if the antidote uninstall is not clean?

CVPR | 2022 | expressed by transformer learning multiple hypotheses! A new framework for 3D human pose estimation!
![[经验教程]支付宝余额自动转入余额宝怎么设置关闭取消支付宝余额自动转入余额宝?](/img/d5/6aa14af59144b8c99aa6a367479f6b.png)
[经验教程]支付宝余额自动转入余额宝怎么设置关闭取消支付宝余额自动转入余额宝?

Detonate the bomb (DFS)
随机推荐
Jerry's AI server [chapter]
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
GBase 8s 备份介绍
Let's talk about passive safety again. I'll teach you to understand the rating report of China Insurance Research Institute collision test
gin--hello
.NET(C#) MySQL conn.Open()报错:SSL Connection error的解决方法
数字藏品平台入驻 数字藏品平台开发 数字藏品SaaS平台
2n queen problem
Introduction to PCIe xdma IP core (with list) - mingdeyang science and Education (mdy edu. Com)
GBASE 8s 共享内存缓冲池介绍
CVPR | 2022 | expressed by transformer learning multiple hypotheses! A new framework for 3D human pose estimation!
ai2022新功能,illustrator 2022 新功能介绍
清研环境深交所上市:年营收1.8亿 市值41亿
Traversal of ladder race l2-6 tree
[course summary] Hello harmonyos series of courses, take you to zero foundation introduction
Gbase 8s检查点简介
01 knapsack problem - and deformation problem
Update description of the latest process engine flowable 6.7.2
In depth analysis of disk cache mechanism and SSD write amplification under Linux
Redis实现分布式锁