UVA 11578 - Situp Benches(dp)】的更多相关文章

题目链接:11578 - Situp Benches 题意:健♂身♂房有两个仰卧起坐坐垫,每次调整角度要花费10元/10度,每次使用要花费15,如今给定n个人的时间顺序,和所希望的角度,求最少花费 思路:dp,dp[i][j][k]表示第i个人,一个角度为j,还有一个为k的最小花费,一个人用和两个人用的情况分开讨论,然后记录dp状态转移路径.这个输出路径让这题变得麻烦了不少.只是机智的我还是把它搞♂出♂来♂了. 代码: #include <stdio.h> #include <strin…
uva 116 Unidirectional TSP Background Problems that require minimum paths through some domain appear in many different areas of computer science. For example, one of the constraints in VLSI routing problems is minimizing wire length. The Traveling Sa…
题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=39  Stacking Boxes  Background Some concepts in Mathematics and Computer Science are simple in one or two dimensions but become…
UVA 674  Coin Change  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/E 题目: Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount o…
Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people's memories about some period of life. A new idea Bill has recently developed assigns a non-negat…
In Frobnia, a far-away country, the verdicts in court trials are determined by a jury consisting of members of the general public. Every time a trial is set to begin, a jury has to be selected, which is done as follows. First, several people are draw…
题意:有一个老板和n个员工,除了老板每个员工都有唯一的上司,老板编号为0,员工们为1-n,工人(没有下属的员工),要交一份请愿书, 但是不能跨级,当一个不是工人的员工接受到直系下属不少于T%的签字时,自己也会签字,并交给上级,问你最少有多少工人签字,才能让老板收到请愿书. 析:题意比较简单,也好理解,很明显是一个动态规划的题目,d(u)表示u给上级要发信至少需要多少工人签字.假设u有k个结点,那么至少要 c = (kT-1)/100 + 1个工人,然后把每个结点排序,找出最少的工人即可,挺简单的…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=465&page=show_problem&problem=2399 最长的很简单,将串翻转过来后求两个串的lcs就是答案.. 主要是字典序那里... 还是开string来比较吧.. 注意最后输出方案时用前半段推出后半段.(因为可能lcs时会重合...) #include <cstdio> #include…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4513 题意: 有高为1, 2, 3,…, n的杆子各一根排成一行.从左边能看到L根,从右边能看到R根,求有多少种可能. 分析: 设d(i,j,k)表示让高度为1-i的杆子排成一行,从左边能看到j根,从右边能看到k根的方案数(设i≥2).按照从大到小的顺序安排各个杆子.假设已经安排完…
题意:有n个长度为1到n的柱子排列在一起,从左边看有l根从右边看有r根,问你所以排列中满足这种情况的方案数 题解:就是一个dp问题,关键是下标放什么,值代表什么 使用三维dp,dp[i][j][k]=l; i:从左边看的个数,j:从右边看的个数,k:后k根柱子,l:方案数 可以这样想:每次加上去的是比当前最小柱子小一的柱子,这样就可以发现,这根柱子放在k个位置都很好判断 即:dp[i][j][k]=dp[i-1][j][k-1](放在最左边)+dp[i][j-1][k-1](放在最右边)+dp[…