Description
Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:
1. Emergency 911
...
分类:
其他好文 时间:
2014-08-08 12:49:16
阅读次数:
187
链接:http://poj.org/problem?id=3641
题意:由费马小定理可得,对于素数p,a^p = a (mod p),但是对于某些非素数p,也有比较小的可能满足a^p = a (mod p),如果满足,则称p是a条件下的伪素数,现给出p,a,问p是不是a条件的伪素数。
思路:首先用米勒 罗宾判断p是不是素数,如果不是,判断a^p = a (mod p)是否成立。
代码:
...
分类:
其他好文 时间:
2014-08-08 12:42:05
阅读次数:
232
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible o...
分类:
其他好文 时间:
2014-08-08 02:06:05
阅读次数:
207
题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique....
分类:
编程语言 时间:
2014-08-08 01:54:55
阅读次数:
292
题意 所有可以表示为4*k+1(k>=0)的数都称为“H数” 而在所有“H数”中只能被1和自身整除的H数称为“H素数“ 能表示成两个”H素数“积的数又称为”Semi-prime H数“
输入n 求1到n之间有多少个”Semi-prime H数“;
方法 先打个H素数表 再用H素数表中的数依次相乘 得到的数都标记 再用一个数组保存每个数以内的标记数 输入n后直接读数组就行了...
分类:
其他好文 时间:
2014-08-07 23:11:35
阅读次数:
265
该题可以用DFS解决,在DFS时记录path,当到达leaf时将path所表示的数加到sum上。 1 class Solution { 2 public: 3 int sumNumbers(TreeNode *root) { 4 vector path; 5 ...
分类:
其他好文 时间:
2014-08-07 18:50:40
阅读次数:
197
1. I am Charles Humble and I am here at QCon London with Eva Andreasson from Cloudera. Eva, can you introduce yourself to the InfoQ community?Who am I...
分类:
其他好文 时间:
2014-08-07 17:59:50
阅读次数:
279
题目You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a singl...
分类:
其他好文 时间:
2014-08-07 12:51:00
阅读次数:
188
题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message....
分类:
编程语言 时间:
2014-08-07 05:11:09
阅读次数:
247
G -Self Numbers(2.2.1)Time Limit:1000MSMemory Limit:10000KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionIn 1949 the Indian mathematician D.R. K...
分类:
其他好文 时间:
2014-08-07 00:27:37
阅读次数:
249