摘要: 题目链接:http://poj.org/problem?id=3414这道题和POJ 1606:http://poj.org/problem?id=1606很像,几乎一模一样,但是本题增加了对无解情况的输出。那么什么情况下会无解呢?定义bool 数组标记每一个状态,搜索过的就不在搜了。这样一直下去,无解时队列会清空(front==rear)或(Q.empty())。队列空了还无解,本题就无解了。 阅读全文
posted @ 2012-09-26 19:19 史力普神 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1655Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 6769Accepted: 2718DescriptionConsider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more trees. Define the balance of a 阅读全文
posted @ 2012-09-26 17:57 史力普神 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1564DescriptionGiven a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1, 1], then there are four different sums that equal 4: 4, 3+1, 2+2, and 2 阅读全文
posted @ 2012-09-26 12:59 史力普神 阅读(201) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn the movie "Die Hard 3",Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug with exactly 4 gallons. This problem generalizes that puzzle.You have two jugs, A and 阅读全文
posted @ 2012-09-26 11:46 史力普神 阅读(198) 评论(0) 推荐(0) 编辑