题目:UVA - 10304Optimal Binary Search Tree(递推)
题目大意:给出一组数,e1 2 n,现在要求将这些数组成一棵二叉搜索树,并且使得sum (ei * cost(ei))最小。cost(ei)表示ei到到根节点之间有多少条边。
解题思路:首先二叉搜索树要满足左节点小于根节点,右节点大于根节点。因此对于e1 2 n这样一组数,我们只要枚举根节...
分类:
其他好文 时间:
2014-08-09 23:19:09
阅读次数:
266
题目:UVA - 620Cellular Structure(递推)
题目大意:只能给出三种细胞的增殖方式,然后给出最后细胞的增殖结果,最后问你这是由哪一种增殖方式得到的。如果可以由多种增殖方式得到,就输出题目中列出来的增殖方式靠前的那种。
解题思路:也是递推,细胞长度长的可以由细胞长度短的推得,并且这里第一种只能是长度为1的细胞才有可能,所以判断的时候可以3个判断,看能否与上...
分类:
其他好文 时间:
2014-08-09 23:17:09
阅读次数:
236
题目:UVA - 10131Is Bigger Smarter?(DAG)
题目大意:给出一群大象的体重和IQ,要求挑选最多的大象,组成一个序列,严格的体重递增,IQ递减的序列。输出最多的大象数目和这些大象的序列(其中一种就可以)。
解题思路:DAG上的DP。和之前的一篇相似。uva437 - The Tower of Babylon(DAG上的DP)。就是将每两只大象满足上面...
分类:
其他好文 时间:
2014-08-09 23:16:19
阅读次数:
273
题目:UVA - 590Always on the run(递推)
题目大意:有一个小偷现在在计划着逃跑的路线,但是又想省机票费。他刚开始在城市1,必须K天都在这N个城市里跑来跑去,最后一天达到城市N,问怎样计划路线的得到最少的费用。
解题思路:一开始题目意思就理解有些问题。
dp【k】【i】:代表在第k天小偷从某一个城市(除了i)坐飞机飞...
分类:
其他好文 时间:
2014-08-09 23:15:39
阅读次数:
338
Hangman Judge
In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are t...
分类:
其他好文 时间:
2014-08-09 21:37:19
阅读次数:
414
Description
Problem F: Tug of War
A tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one tea...
分类:
其他好文 时间:
2014-08-09 21:37:09
阅读次数:
367
Palindromes
A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when t...
分类:
其他好文 时间:
2014-08-09 21:36:09
阅读次数:
344
Overflow
Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be rep...
分类:
其他好文 时间:
2014-08-09 21:35:29
阅读次数:
321
Description
Problem B.Last Digit
Background
Give you a integer number N (1100). Pleasecompute
S=11+22+33+…+NN
Give the last digit of S to me.
Input
...
分类:
其他好文 时间:
2014-08-09 21:30:19
阅读次数:
211
Description
Problem E: Chainsaw Massacre
Background
As every year the Canadian Lumberjack Society has just held its annual woodcutting competition and the national forest...
分类:
其他好文 时间:
2014-08-09 18:53:58
阅读次数:
261