当前位置:网站首页>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)
边栏推荐
- 【大型电商项目开发】性能压测-优化-中间件对性能的影响-40
- Database postragesq PAM authentication
- Interesting practice of robot programming 14 robot 3D simulation (gazebo+turtlebot3)
- Game 280 of leetcode week
- Main window in QT application
- 微信小程序;胡言乱语生成器
- Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue
- 增量备份 ?db full
- Win: add general users to the local admins group
- Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
猜你喜欢

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

Nebula importer data import practice

To sort out messy header files, I use include what you use

Main window in QT application

【CTF】AWDP总结(Web)

MySQL regexp: Regular Expression Query

Introduction to redis (1)

Basic operations of database and table ----- delete index

微信小程序:全新独立后台月老办事处一元交友盲盒

Mysql database | build master-slave instances of mysql-8.0 or above based on docker
随机推荐
Win: use shadow mode to view the Desktop Session of a remote user
微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化
Global and Chinese markets of emergency rescue vessels (errv) 2022-2028: Research Report on technology, participants, trends, market size and share
PHP Basics - detailed explanation of DES encryption and decryption in PHP
Vulnstack3
Five ways to query MySQL field comments!
Database postragesql client connection default
ROS command line tool
142. Circular linked list II
Can financial products be redeemed in advance?
After reading the average code written by Microsoft God, I realized that I was still too young
微信小程序:独立后台带分销功能月老办事处交友盲盒
【大型电商项目开发】性能压测-优化-中间件对性能的影响-40
Remote control service
One plus six brushes into Kali nethunter
Numpy library introductory tutorial: basic knowledge summary
The server time zone value ‘� й ��� ʱ 'is unrecognized or representatives more than one time zone【
When the industrial Internet era is truly developed and improved, it will witness the birth of giants in every scene
力扣剑指offer——二叉树篇
If the consumer Internet is compared to a "Lake", the industrial Internet is a vast "ocean"