摘要: 标题就说明了方法 。。 典型的dp题目:Problem C: Longest Common SubsequenceSequence 1: Sequence 2: Given two sequences of characters, print thelength of the longest common subsequence of both sequences. Forexample, the longest common subsequence of the following twosequences:abcdghaedfhris adh of leng... 阅读全文
posted @ 2013-12-28 11:09 doubleshik 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 题目的数据一开始有点不懂。。 3 2 1 表示第一个事情发生在时间三, 第二个事情发生在时间二,第一个事情发生在时间一。。建立好之后就是经典的dp 。题目:History GradingBackgroundMany problems in Computer Science involve maximizing some measure according to constraints.Consider a history exam in which students are asked to put several historical events into chronological or 阅读全文
posted @ 2013-12-27 11:16 doubleshik 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 给出一些点,看最多有多少个点在同一个直线上。用每一个点作为起点,枚举与其他点的斜率,找出最大值。注意输出格式 和初始化最小ans为2;题目:Lining Up``How am I ever going to solve this problem?" said the pilot.Indeed, the pilot was not facing an easy task. She had to drop packages at specific points scattered in a dangerous area. Furthermore, the pilot could only 阅读全文
posted @ 2013-12-26 22:30 doubleshik 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 题目给出一个n ,求所有a/b=n 要求ab中数字不一样 枚举分母或者分分子就行了注意输出格式题目: DivisionWrite a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided by the second is equal to an integer N, where . That is, abcde / fghij = Nwhere e 阅读全文
posted @ 2013-12-25 21:58 doubleshik 阅读(379) 评论(0) 推荐(0) 编辑
摘要: http://www.matrix67.com/blog/archives/20 阅读全文
posted @ 2013-12-25 00:13 doubleshik 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 就是一个文件的很多副本碎成两半, 让你根据所有碎片求出原来的文件排序枚举一下就ok了题目:Question 2: File FragmentationThe ProblemYour friend, a biochemistry major, tripped while carrying a tray of computer files through the lab. All of the files fell to the ground and broke. Your friend picked up all the file fragments and called you to ask 阅读全文
posted @ 2013-12-24 21:54 doubleshik 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 一道动态规划 F(x ) = max (F[x-1] + a[x] ,a[x])题目:Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123249Accepted Submission(s): 28497Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequenc 阅读全文
posted @ 2013-12-24 20:22 doubleshik 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目就是求能否匹配所有交流生,让他们互相换。 。 一开始第一反应是训练指南上第一道勇士杀龙问题,利用排序比较。。虽然过了但是网上看到一个反例。。就是10 20,20 30,30 10,。。。 一个正确得方法是利用图的思想(有点类似跷跷板。具体看连接中博客吧)题目:Problem EForeign ExchangeInput: standard inputOutput: standard outputTime Limit: 1 secondYour non-profit organization (iCORE - international Confederation ofRevolver En 阅读全文
posted @ 2013-12-24 00:11 doubleshik 阅读(613) 评论(1) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 bool cmp(string a,string b) 7 { 8 return a+b>b+a; 9 }10 11 void solve(int n)12 {13 string a[100];14 for(int i=0;i>a[i];17 }18 19 sort(a,a+n,cmp);20 for(int i=0;i>n && n)32 {33 solve(n);34 }35 36 ... 阅读全文
posted @ 2013-12-23 23:54 doubleshik 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 利用set 进行判断重复, 可以用dfs 因为只有11步。 我这里用了bfs题目:Problem DKnights in FENInput: standard inputOutput: standard outputTime Limit: 10 secondsThere are black and white knights on a 5 by 5 chessboard. There are twelve of each color, and there is one square that is empty. At any time, a knight can move into an em 阅读全文
posted @ 2013-12-23 15:06 doubleshik 阅读(245) 评论(0) 推荐(0) 编辑