ZOJ 2702 Unrhymable Rhymes(DP)】的更多相关文章

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1702 题目大意:给定有很多数字组成的诗,譬如 “AABB”, “ABAB”, “ABBA” and “AAAA”形式的诗句是押韵的.从中挑选,求最多可以构成多少押韵句,并且输出这些句子在原序列中的位置. Sample Input 15 1 2 3 1 2 1 2 3 3 2 1 1 3 2 2 3 1 2 3 Sample Output 3 1 2 4 5 7 8…
题意:一串括号,每个括号代表一个值,当有相邻括号组成()时,可以交换他们两个并得到他们值的乘积,问你最大能得到多少 思路:DP题,注定想得掉头发. 显然一个左括号( 的最远交换距离由他右边的左括号的最终位置决定,那么我们可以从右边开始做.我们用dp[i][j]表示第i个左括号交换到第j个位置后,他和他后面左括号所能得到的最大值.显然,dp[i][j] = i交换得到的值 + 后面左括号产生的最大值.而后面左括号能产生的最大值显然就是max(dp[i+1][k])其中j <= k <= n. 代…
贪心.能凑成一组就算一组 Unrhymable Rhymes Time Limit: 10 Seconds      Memory Limit: 32768 KB      Special Judge An amateur poet Willy is going to write his first abstract poem. Since abstract art does not give much care to the meaning of the poem, Willy is plan…
Unrhymable Rhymes Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description An amateur poet Willy is going to write his first abstract poem. Since abstract art does not give much care to the meaning of the poem, Willy is…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1625 题目大意:将n个数重新排列,使得每个数的前一个数都不能和之前的一样,求一共有多少种排列方法 ample Input: 3 4 Sample Output: 3 11 分析: CrazyAC's 解题报告: 本题一道DP题 仔细想想不难的 首先我们确定状态F[N]表示所产生的新排列的情况数 那么F[N]=f(F[N-1]) 怎么来确定他呢? 由于F[N-1]是排…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1745 题目大意:一个串由N个字符组成,每个字符是‘0’或者是‘1’,在任意一段连续的子序列中,要求0和1的个数的差不超过K,求一共有多少种这样的串,比如N=4,K=3时,除了0000和1111外的其他四个字符的串都符合要求. Sample Input 1 2 4 3 Sample Output 2 14 分析: 这种涉及到任意子区间的性质的问题,如果每个子区间都考虑…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=13 题目大意:说的是有三种不同的装备,分别是头盔,盔甲,战靴需要运输,每种装备拥有不同的重量,体积,以及防御能力.当三种装备按照一定的数量规定组合成套装时,套装可以发挥处更强的攻击能力.然后有n个运输车,每个车能够运送的重量和体积有限制,现在问如何给这个n个运输车分配运送任务(即每个运输队运多少头盔,多少盔甲,多少战靴) 可以获得总的防御值最大. 输入描述:第一行是运…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3374 题目大意:JAVAMAN 到梦幻城市旅游见到了黄金树,黄金树上每天回结出金子.已经有n棵树,JAVAMAN要停留m天,每天只能砍掉一棵树,砍掉树后就能得到树上的黄金.给定n棵树上原有的黄金a[i]和每天可以新增加的黄金b[i],求他最多可以得到多少黄金.中途如果有1天不砍树的话,之后的日子久不能砍树,所有最好每天都砍树,或者直到树被砍完. Sample Inp…
LightOJ 1033  Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/A 题目: Description By definition palindrome is a string which is not changed when reversed. "MADAM" is a nice example of palindrome.…
lightOJ 1047   Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/C 题目: Description The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two n…