判断合法数字,之前好像在哪里看到过这题,记得当时还写了好久,反正各种改,今天看到了大神的解法(https://github.com/fuwutu/LeetCode/blob/master/Valid%20Number.cpp),用有限状态机,非常简洁,不需要复杂的各种判断!先枚举一下各种合法的输入情...
分类:
其他好文 时间:
2015-04-24 10:30:20
阅读次数:
162
Balanced Number
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 2640 Accepted Submission(s): 1196
Problem Description
A balance...
分类:
其他好文 时间:
2015-04-24 09:20:38
阅读次数:
151
Problem Description
You have a dice with m faces, each face contains a distinct number. We assume when we tossing the dice, each face will occur randomly and uniformly. Now you have T query to answer...
分类:
其他好文 时间:
2015-04-24 09:14:08
阅读次数:
131
原题链接
解题报告:
由于最大能达到10^7! 故而不能直接用高精度整数算出结果,然后取位数……所以转换思路,从数学角度算出n!的位数,推导如下:
因为len(n)=floor( log10(n) )+1
设A=n!=1*2*3*...*n
所以len(A)-1=floor( log10(A) )=floor( log10(1*2*3*...*n) )=floor( lo...
分类:
其他好文 时间:
2015-04-24 09:06:32
阅读次数:
115
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o...
分类:
移动开发 时间:
2015-04-24 09:03:57
阅读次数:
117
PL/SQL块结构(block)块是进行PL/SQL程序开发时最基本的单位,所有的PL/SQL程序都是由块组成。块可以分成匿名块和命名块匿名块是没有名称的PL/SQL语句块,通常是客户端临时产生,以产生相应结果,数据库不需要存储;命名块就是有名称的PL/SQL语句块,通常在服务器断产生,并且存..
分类:
数据库 时间:
2015-04-24 01:11:10
阅读次数:
162
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon...
分类:
其他好文 时间:
2015-04-24 01:04:53
阅读次数:
138
题目链接:https://leetcode.com/problems/happy-number/这道题看上去很简单,如果用hashtable的话,不少童鞋应该都能做出来。只要想明白一件事儿,循环结束的条件:要么当前的数字为1,要么当前的数字曾经出现过。(至于为什么一定会出现循环,额,数学家们已有讨论...
分类:
移动开发 时间:
2015-04-24 00:58:20
阅读次数:
181
POJ 1351 Number of Locks (记忆化搜索 状态压缩)...
分类:
其他好文 时间:
2015-04-23 23:30:17
阅读次数:
183
Scala 禁止case class inheritancecase class Person(name: String, age: Int)case class FootballPlayer(name: String, age: Int, number: Int) extends Person(n...
分类:
其他好文 时间:
2015-04-23 23:23:16
阅读次数:
299