题目:
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3....
分类:
其他好文 时间:
2014-08-03 23:29:46
阅读次数:
283
HDU 4002 Find the maximum(数论-欧拉函数)
题目大意:
给定一个n,问你1~n中,求一个数 x 使得 x/φ(x) 的值最大。
解题思路:
根据欧拉函数的公式,φ(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn)
则:x/φ(x)=p1/(p1-1)*p2/(p2-1)*......*pn/(pn-1)
可以看出项越多x/φ(x)越大,且因子越小x/φ(x)越大,那么只需要2*3*5*7....
考虑到数字很大,所以用JAVA来写...
分类:
其他好文 时间:
2014-08-03 23:16:46
阅读次数:
268
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to us...
分类:
其他好文 时间:
2014-08-03 23:10:36
阅读次数:
179
题目连接:Sherlock and MiniMaxWatson gives Sherlock an arrayA1,A2...AN.He asks him to find an integerMbetweenPandQ(both inclusive), such that,min {|Ai-M|, ...
分类:
其他好文 时间:
2014-08-03 23:04:06
阅读次数:
380
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:
其他好文 时间:
2014-08-03 22:59:56
阅读次数:
259
题目大意:
T组测试数据,n个人,m组询问,2个帮派,D a b 表示 a,b 不在同一帮派 ,A a b表示查询a和b的关系。
解题思路:
并查集。将每个人对应两个节点,分属于两个帮派。1~n表示帮派1中的,n+1~2n表示帮派2中的。若知道a和b不是同一帮的,那么将a和b+n放到一个集合中,b和a+n放到一个集合中。并查集查询a和b的关系时,如果a与b+n在一个集合中,则说明他们不在同一帮;若a和b在同一集合,则在同一帮;否则说明他们关系不确定。连线时交叉连,即保证间隔两人在同一集合。即敌人的敌人是朋友...
分类:
其他好文 时间:
2014-08-03 18:12:36
阅读次数:
302
Give two versions of WA code:
Version 1: Runtime Error: Find the bug
class Solution {
public:
void find(const string& s, const unordered_set& dict, vector& res) {
int i, j, len = s.length();
...
分类:
其他好文 时间:
2014-08-03 15:21:27
阅读次数:
329
题目大意:
有n个罪犯被逮到。他们分别属于两个团伙。而且每个团伙里至少有一个人
D a b 说明 a b 不是一个团伙的。
A a b 询问a b 是不是一个团伙的。
思路分析:
开始想的是如果a b 不是一个团伙,就把a 和 n+1 并,b和n+2 并。
但是看看下面这组数据就知道是错了。
1
4 4
D 1 2
D 3 4
D 1 4
A 1 3
不是直接...
分类:
其他好文 时间:
2014-08-03 15:17:35
阅读次数:
182
Description
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city counci...
分类:
其他好文 时间:
2014-08-03 15:17:15
阅读次数:
301
1 查看查询计划 db.user.find({"username":"xxx"}) .explain() db.doc.find({"es_y":"2014"}).explain() { ?"cursor" : "BasicCursor", ?"isMultiKey" : false, ?"n" : 0, ?"nscannedObjects" : 1, ?"nscann...
分类:
数据库 时间:
2014-08-03 12:56:45
阅读次数:
268