当前位置:网站首页>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)
边栏推荐
- Express routing, express middleware, using express write interface
- Global and Chinese markets for stratospheric UAV payloads 2022-2028: Research Report on technology, participants, trends, market size and share
- Expansion operator: the family is so separated
- batchnorm.py这个文件单GPU运行报错解决
- Armv8-a programming guide MMU (3)
- Remote control service
- Robley's global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
- Complex, complicated and numerous: illustration of seven types of code coupling
- PowerShell:在代理服务器后面使用 PowerShell
- Interesting practice of robot programming 15- autoavoidobstacles
猜你喜欢

Basic operation of database and table ----- the concept of index

增量备份 ?db full

Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)

Complex, complicated and numerous: illustration of seven types of code coupling

ROS command line tool

phpstrom设置函数注释说明

"2022" is a must know web security interview question for job hopping

Exploration and Practice of Stream Batch Integration in JD

JS implementation determines whether the point is within the polygon range

Introduction to redis (1)
随机推荐
Discrete mathematics: reasoning rules
Include rake tasks in Gems - including rake tasks in gems
Five ways to query MySQL field comments!
Complex, complicated and numerous: illustration of seven types of code coupling
How to safely eat apples on the edge of a cliff? Deepmind & openai gives the answer of 3D security reinforcement learning
La jeunesse sans rancune de Xi Murong
Global and Chinese market of veterinary thermometers 2022-2028: Research Report on technology, participants, trends, market size and share
Heartless sword English translation of Xi Murong's youth without complaint
Wechat applet: independent background with distribution function, Yuelao office blind box for making friends
Database postragesq PAM authentication
Discrete mathematics: Main Normal Form (main disjunctive normal form, main conjunctive normal form)
無心劍英譯席慕容《無怨的青春》
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
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Common bit operation skills of C speech
PHP 约瑟夫环问题
What is the length of SHA512 hash string- What is the length of a hashed string with SHA512?
The server time zone value ‘� й ��� ʱ 'is unrecognized or representatives more than one time zone【
Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化