当前位置:网站首页>172. Zero after factorial
172. Zero after factorial
2022-07-05 01:42:00 【The_ Dan】
Think first 0 How it came about : factor 2 x factor 5 Will appear at the end 0
So do we calculate the factor in the process 2 And factor 5 The number of is enough ?
But in fact, calculation 5 How many times can it appear , Because in the process 2 The number of must be higher than 5 A lot more , It's easy to understand , There will be at least one two in even numbers .
class Solution {
public:
int trailingZeroes(int n) {
int ans;
int five = 0;
while(n){
int temp = n;
while(temp % 5 == 0){
five++;
temp /= 5;
}
n--;
}
return five;
}
};
Accepted
500/500 cases passed (0 ms)
Your runtime beats 100 % of cpp submissions
Your memory usage beats 66.85 % of cpp submissions (5.8 MB)
边栏推荐
- [OpenGL learning notes 8] texture
- Interesting practice of robot programming 14 robot 3D simulation (gazebo+turtlebot3)
- Four pits in reentrantlock!
- Mysql database | build master-slave instances of mysql-8.0 or above based on docker
- Yyds dry goods inventory kubernetes management business configuration methods? (08)
- Pytorch fine tuning (Fortune): hollowed out design or cheating
- WCF: expose unset read-only DataMember property- WCF: Exposing readonly DataMember properties without set?
- Redis' hyperloglog as a powerful tool for active user statistics
- Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
- Vulnstack3
猜你喜欢

【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
![[OpenGL learning notes 8] texture](/img/77/a4a784a535ea6f4c2382857b266cec.jpg)
[OpenGL learning notes 8] texture

微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化

Game 280 of leetcode week
![[CTF] AWDP summary (WEB)](/img/4c/574742666bd8461c6f9263fd6c5dbb.png)
[CTF] AWDP summary (WEB)

Actual combat simulation │ JWT login authentication

【大型电商项目开发】性能压测-优化-中间件对性能的影响-40

微信小程序;胡言乱语生成器

Remote control service

MATLB | multi micro grid and distributed energy trading
随机推荐
Armv8-a programming guide MMU (3)
220213c language learning diary
Interesting practice of robot programming 15- autoavoidobstacles
To sort out messy header files, I use include what you use
Yyds dry inventory swagger positioning problem ⽅ formula
MATLB|多微电网及分布式能源交易
DOM basic syntax
Can financial products be redeemed in advance?
Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
Hedhat firewall
Roads and routes -- dfs+topsort+dijkstra+ mapping
Wechat applet: Xingxiu UI v1.5 WordPress system information resources blog download applet wechat QQ dual end source code support WordPress secondary classification loading animation optimization
Interpretation of mask RCNN paper
One click generation and conversion of markdown directory to word format
Introduction to the gtid mode of MySQL master-slave replication
微信小程序:最新wordpress黑金壁纸微信小程序 二开修复版源码下载支持流量主收益
Flutter 2.10 update details
PHP Joseph Ring problem
Es uses collapsebuilder to de duplicate and return only a certain field
Lsblk command - check the disk of the system. I don't often use this command, but it's still very easy to use. Onion duck, like, collect, pay attention, wait for your arrival!