当前位置:网站首页>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)
边栏推荐
- Database postragesql client connection default
- A simple SSO unified login design
- Numpy library introductory tutorial: basic knowledge summary
- MATLB|多微电网及分布式能源交易
- 【CTF】AWDP总结(Web)
- Introduction to redis (1)
- Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
- Global and Chinese markets of emergency rescue vessels (errv) 2022-2028: Research Report on technology, participants, trends, market size and share
- [development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40
- 增量备份 ?db full
猜你喜欢
Wechat applet; Gibberish generator
Async/await you can use it, but do you know how to deal with errors?
Comment mettre en place une équipe technique pour détruire l'entreprise?
Win:使用 Shadow Mode 查看远程用户的桌面会话
Wechat applet: new independent backstage Yuelao office one yuan dating blind box
Game 280 of leetcode week
How to safely eat apples on the edge of a cliff? Deepmind & openai gives the answer of 3D security reinforcement learning
Win: use shadow mode to view the Desktop Session of a remote user
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
Behind the cluster listing, to what extent is the Chinese restaurant chain "rolled"?
随机推荐
Redis' hyperloglog as a powerful tool for active user statistics
Can financial products be redeemed in advance?
无心剑英译席慕容《无怨的青春》
微信小程序:全网独家小程序版本独立微信社群人脉
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
When the industrial Internet era is truly developed and improved, it will witness the birth of giants in every scene
Exploration and Practice of Stream Batch Integration in JD
What sparks can applet container technology collide with IOT
Mysql database | build master-slave instances of mysql-8.0 or above based on docker
Application and development trend of image recognition technology
19. Delete the penultimate node of the linked list
Interesting practice of robot programming 15- autoavoidobstacles
PHP Basics - detailed explanation of DES encryption and decryption in PHP
Roads and routes -- dfs+topsort+dijkstra+ mapping
Change the background color of a pop-up dialog
Basic operations of database and table ----- create index
Database postragesq peer authentication
PHP wechat official account development
Summary of regularization methods
Comment mettre en place une équipe technique pour détruire l'entreprise?