04 2015 档案

[hihoCoder] #1055 : 刷油漆
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了不同的数字,并且这些数字都是处于1..N的范围之内,每根木棍都连接着两个不同的小球,并且保证任意两个小球间都不存在两... 阅读全文

posted @ 2015-04-30 14:23 Eason Liu 阅读(775) 评论(0) 推荐(0)

[LeetCode] Isomorphic Strings
摘要:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文

posted @ 2015-04-29 12:51 Eason Liu 阅读(5191) 评论(0) 推荐(0)

[Codility] CommonPrimeDivisors
摘要:Aprimeis a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13.A prime D is cal... 阅读全文

posted @ 2015-04-28 19:37 Eason Liu 阅读(965) 评论(0) 推荐(0)

[Codility] CountTriangles
摘要:A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) istriangularif it is possible to build a triangle with sides of lengths ... 阅读全文

posted @ 2015-04-28 18:16 Eason Liu 阅读(449) 评论(0) 推荐(0)

[hihoCoder] #1158 : 质数相关
摘要:时间限制:2000ms单点时限:1000ms内存限制:256MB描述两个数a和 b (a 2 using namespace std; 3 4 int T, N; 5 vector v; 6 vector> graph; 7 vector link; 8 vector visited; 9 boo... 阅读全文

posted @ 2015-04-28 16:40 Eason Liu 阅读(376) 评论(0) 推荐(0)

[hihoCoder] #1122 : 二分图二•二分图最大匹配之匈牙利算法
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述上一回我们已经将所有有问题的相亲情况表剔除了,那么接下来要做的就是安排相亲了。因为过年时间并不是很长,所以姑姑希望能够尽可能在一天安排比较多的相亲。由于一个人同一天只能和一个人相亲,所以要从当前的相亲情况表里选择尽可能多的组合,且... 阅读全文

posted @ 2015-04-28 16:14 Eason Liu 阅读(918) 评论(0) 推荐(0)

[Jobdu] 题目1500:出操队形
摘要:题目描述:在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往楼下跑了,然后身高矮的排在队伍的前面,身高较高的就要排在队尾。突然,有一天出操负责人想了一个主意,想要变换一下队形,就是当大家都从楼上跑下来后,所有的学生都随机地占在一排,然后出操负责人从队伍中... 阅读全文

posted @ 2015-04-28 00:56 Eason Liu 阅读(361) 评论(0) 推荐(0)

[Leetcode] Count Primes
摘要:Description:Count the number of prime numbers less than a non-negative number,nHint:The number n could be in the order of 100,000 to 5,000,000.click t... 阅读全文

posted @ 2015-04-27 22:58 Eason Liu 阅读(2009) 评论(0) 推荐(1)

[hihoCoder] #1032 : 最长回文子串
摘要:时间限制:1000ms单点时限:1000ms内存限制:64MB描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一连串的字符串,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能分别在这些字符串中... 阅读全文

posted @ 2015-04-24 18:39 Eason Liu 阅读(3391) 评论(0) 推荐(1)

[Codility] MaxDoubleSliceSum
摘要:A non-empty zero-indexed array A consisting of N integers is given.A triplet (X, Y, Z), such that 0 ≤ X 3 4 // you can write to stdout for debugging... 阅读全文

posted @ 2015-04-24 14:08 Eason Liu 阅读(433) 评论(0) 推荐(0)

[Leetcode] Remove Linked List Elements
摘要:Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文

posted @ 2015-04-23 19:20 Eason Liu 阅读(1799) 评论(0) 推荐(0)

[Leetcode] Happy Number
摘要: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... 阅读全文

posted @ 2015-04-22 20:25 Eason Liu 阅读(236) 评论(0) 推荐(0)

[剑指Offer] 数据流中的中位数
摘要:题目描述如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。对于数据流,对应的就是在线算法了,一道很经典的题目就是在1亿个数中找到最大的前100个数,这是一道堆应用题... 阅读全文

posted @ 2015-04-20 16:33 Eason Liu 阅读(10090) 评论(0) 推荐(2)

[hihoCoder] 骨牌覆盖问题·二
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述上一周我们研究了2xN的骨牌问题,这一周我们不妨加大一下难度,研究一下3xN的骨牌问题?所以我们的题目是:对于3xN的棋盘,使用1x2的骨牌去覆盖一共有多少种不同的覆盖方法呢?首先我们可以肯定,奇数长度一定是没有办法覆盖的;对于偶... 阅读全文

posted @ 2015-04-18 23:36 Eason Liu 阅读(3151) 评论(0) 推荐(0)

[Jobdu] 题目1545:奇怪的连通图
摘要:题目描述:已知一个无向带权图,求最小整数k。使仅使用权值小于等于k的边,节点1可以与节点n连通。输入:输入包含多组测试用例,每组测试用例的开头为一个整数n(1 2 #include 3 #include 4 #include 5 using namespace std; 6 7 stru... 阅读全文

posted @ 2015-04-15 17:39 Eason Liu 阅读(258) 评论(0) 推荐(0)

[hihoCoder] #1044 : 状态压缩·一
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho在兑换到了喜欢的奖品之后,便继续起了他们的美国之行,思来想去,他们决定乘坐火车前往下一座城市——那座城市即将举行美食节!但是不幸的是,小Hi和小Ho并没有能够买到很好的火车票——他们只能够乘坐最为破旧的火车进行他们的... 阅读全文

posted @ 2015-04-13 17:42 Eason Liu 阅读(1478) 评论(0) 推荐(0)

[hihoCoder] #1096 : Divided Product
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述Given two positive integers N and M, please divide N into several integers A1, A2, ..., Ak (k >= 1), so that:1. 0 ... 阅读全文

posted @ 2015-04-13 17:37 Eason Liu 阅读(425) 评论(0) 推荐(0)

[hihoCoder] 骨牌覆盖问题·一
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述骨牌,一种古老的玩具。今天我们要研究的是骨牌的覆盖问题:我们有一个2xN的长条形棋盘,然后用1x2的骨牌去覆盖整个棋盘。对于这个棋盘,一共有多少种不同的覆盖方法呢?举个例子,对于长度为1到3的棋盘,我们有下面几种覆盖方式:提示:骨... 阅读全文

posted @ 2015-04-12 14:15 Eason Liu 阅读(4305) 评论(5) 推荐(2)

[hihoCoder] #1093 : 最短路径·三:SPFA算法
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述万圣节的晚上,小Hi和小Ho在吃过晚饭之后,来到了一个巨大的鬼屋!鬼屋中一共有N个地点,分别编号为1..N,这N个地点之间互相有一些道路连通,两个地点之间可能有多条道路连通,但是并不存在一条两端都是同一个地点的道路。不过这个鬼屋虽... 阅读全文

posted @ 2015-04-08 15:57 Eason Liu 阅读(399) 评论(0) 推荐(0)

[hihoCoder] #1089 : 最短路径·二:Floyd算法
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述万圣节的中午,小Hi和小Ho在吃过中饭之后,来到了一个新的鬼屋!鬼屋中一共有N个地点,分别编号为1..N,这N个地点之间互相有一些道路连通,两个地点之间可能有多条道路连通,但是并不存在一条两端都是同一个地点的道路。由于没有肚子的压... 阅读全文

posted @ 2015-04-08 15:56 Eason Liu 阅读(538) 评论(0) 推荐(0)

[LeetCode] Number of Islands
摘要:Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent ... 阅读全文

posted @ 2015-04-08 12:37 Eason Liu 阅读(3091) 评论(0) 推荐(0)

[LeetCode] Word Ladder
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文

posted @ 2015-04-08 12:23 Eason Liu 阅读(325) 评论(0) 推荐(0)

[hihoCoder] #1081 : 最短路径·一
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述万圣节的早上,小Hi和小Ho在经历了一个小时的争论后,终于决定了如何度过这样有意义的一天——他们决定去闯鬼屋!在鬼屋门口排上了若干小时的队伍之后,刚刚进入鬼屋的小Hi和小Ho都颇饥饿,于是他们决定利用进门前领到的地图,找到一条通往... 阅读全文

posted @ 2015-04-07 17:17 Eason Liu 阅读(630) 评论(0) 推荐(0)

[Leetcode] Binary Tree Right Side View
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文

posted @ 2015-04-05 00:04 Eason Liu 阅读(228) 评论(0) 推荐(0)

[LeetCode] Sort Colors
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2015-04-01 16:26 Eason Liu 阅读(333) 评论(0) 推荐(0)

[LeetCode] House Robber
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文

posted @ 2015-04-01 15:31 Eason Liu 阅读(214) 评论(0) 推荐(0)