【leetcode】Factorial Trailing Zeroes(easy)
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
思路:编程之美里有,就是找因子5的个数。
int trailingZeroes(int n) {
int ans = ;
while(n > )
{
ans += n / ;
n /= ;
}
return ans;
}
【leetcode】Factorial Trailing Zeroes(easy)的更多相关文章
- 【leetcode】Factorial Trailing Zeroes
题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...
- 【leetcode】Set Matrix Zeroes(middle)
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 思路:不能用 ...
- 【leetcode】Reverse Linked List(easy)
Reverse a singly linked list. 思路:没啥好说的.秒... ListNode* reverseList(ListNode* head) { ListNode * rList ...
- 【leetcode】Count and Say (easy)
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...
- 【leetcode】Longest Common Prefix (easy)
Write a function to find the longest common prefix string amongst an array of strings. 思路:找最长公共前缀 常规 ...
- 【LeetCode】数组--合并区间(56)
写在前面 老粉丝可能知道现阶段的LeetCode刷题将按照某一个特定的专题进行,之前的[贪心算法]已经结束,虽然只有三个题却包含了简单,中等,困难这三个维度,今天介绍的是第二个专题[数组] 数组( ...
- LeetCode 172. Factorial Trailing Zeroes (阶乘末尾零的数量)
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- 【leetcode】Number of Islands(middle)
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- 【LeetCode】Agorithms 题集(一)
Single Number 题目 Given an array of integers, every element appears twice except for one. Find that s ...
随机推荐
- [Kerberos] How to Kerberize an Hadoop Cluster
Overview Kerberos是一个第三方认证机制,用户和服务(known as principals)通过kerberos server (known as the Key Distributi ...
- Javascript包含对象的数组去重
Array.prototype.clearRepeat = function(){ var result = [], obj = {}; for(var i = 0; i < this.leng ...
- Android Fragment完全解析,关于碎片你所需知道的一切
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/8881711 我们都知道,Android上的界面展示都是通过Activity实现的, ...
- ionic隐藏tabs方法
<ion-tabs ng-class="{'tabs-item-hide': $root.hideTabs}"> <!-- tabs --> </io ...
- ionic不同view跳转到同一个
ionic不同view跳转到同一个 view并保留历史的路由设计 上代码:state 里面新加一个状态 .state("other", { url: "/other&qu ...
- 剑指Offer 调整数组顺序使奇数位于偶数前面
题目描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变. 思路: ...
- OpenCv haar+SVM训练的xml检测人头位置
注意:opencv-2.4.10 #include "stdio.h"#include "string.h"#include "iostream&qu ...
- JavaScript中var关键字的使用详解
作用 声明作用:如声明个变量. 语法 ? 1 var c = 1; 省略var 在javascript中,若省略var关键字而直接赋值,那么这个变量为全局变量,哪怕是在function里定义的. ? ...
- Python自动化之常用模块
1 time和datetime模块 #_*_coding:utf-8_*_ __author__ = 'Alex Li' import time # print(time.clock()) #返回处理 ...
- django 添加动态表格的方法
传统方法(基于方法的视图):http://stellarchariot.com/blog/2011/02/dynamically-add-form-to-formset-using-javascrip ...