math
i-Blue
抱平常心走平常路
展开
-
172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.重点在于质因数的运用。一个数的阶乘可以写成其所有质数的n次方相乘的形式,例如:10!= 2^8 * 3^4 *原创 2016-09-28 21:23:20 · 230 阅读 · 0 评论 -
326. Power of Three / 342. Power of Four
Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?代码:class Solution {public: bool isPowerOfThree(i原创 2016-10-22 20:12:37 · 278 阅读 · 0 评论 -
204. Count Primes_找n以内的质数_hash
题目以及解法思路答案在原网页上都有。https://leetcode.com/problems/count-primes/Description:Count the number of prime numbers less than a non-negative number, n.Hint:Let's start with a isPrime function.原创 2016-12-08 20:03:58 · 349 阅读 · 0 评论