当前位置:网站首页>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)
边栏推荐
- 微信小程序:独立后台带分销功能月老办事处交友盲盒
- Win: use shadow mode to view the Desktop Session of a remote user
- [Chongqing Guangdong education] National Open University spring 2019 1042 international economic law reference questions
- runc hang 导致 Kubernetes 节点 NotReady
- Do you know the eight signs of a team becoming agile?
- Discrete mathematics: reasoning rules
- Jcenter () cannot find Alibaba cloud proxy address
- 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
- Roads and routes -- dfs+topsort+dijkstra+ mapping
- The server time zone value ‘� й ��� ʱ 'is unrecognized or representatives more than one time zone【
猜你喜欢
Basic operations of database and table ----- delete index
Roads and routes -- dfs+topsort+dijkstra+ mapping
PHP wechat official account development
Incremental backup? db full
微信小程序:独立后台带分销功能月老办事处交友盲盒
Codeforces Global Round 19 ABC
One plus six brushes into Kali nethunter
[swagger]-swagger learning
Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and mobile phones can also easily read literature
Yyds dry goods inventory kubernetes management business configuration methods? (08)
随机推荐
C basic knowledge review (Part 3 of 4)
Blue Bridge Cup Square filling (DFS backtracking)
Valentine's Day flirting with girls to force a small way, one can learn
Basic operations of database and table ----- delete index
Yyds dry inventory swagger positioning problem ⽅ formula
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
C语音常用的位运算技巧
Redis' hyperloglog as a powerful tool for active user statistics
流批一體在京東的探索與實踐
One plus six brushes into Kali nethunter
PHP 基础篇 - PHP 中 DES 加解密详解
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
When the industrial Internet era is truly developed and improved, it will witness the birth of giants in every scene
线上故障突突突?如何紧急诊断、排查与恢复
Flutter 2.10 update details
pytorch fine-tuning (funtune) : 镂空设计or 偷梁换柱
Basic operations of database and table ----- create index
微信小程序:独立后台带分销功能月老办事处交友盲盒
Wechat applet: wechat applet source code download new community system optimized version support agent member system function super high income
MySQL regexp: Regular Expression Query