![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DP
Rocky0429
我愿能朝着太阳生长,做一个温暖的人。
展开
-
POJ 3176-Cow Bowling(dp_数字三角形)
Cow BowlingTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionThe cows don't use actual bowling balls when they go bowling. They ea原创 2015-01-28 14:39:38 · 1429 阅读 · 0 评论 -
POJ 1458-Common Subsequence(dp之最长公共子序列)
题目地址:POJ 1458 题意:给出两个序列X 和Y,你的任务是找到X 和Y 的最大公共子序列,也就是说要找到一个最长的序列Z,使得Z 既是X 的子序列也是Y 的子序列。 思路:最长公共子序列的裸题,关于最长公共子序列问题,请看最长公共子序列#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>原创 2015-08-18 19:40:21 · 1371 阅读 · 0 评论 -
UVA 147- Dollars(dp之子集和问题)
题目地址:UVA 147 题意:给定11种面值分别为100元, 50元, 20元, 10元, and 5元 and 2元, 1元, 50分, 20分, 10分 and 5分的钱,现在给定一个钱数,求出可以组成的种类数。 思路:子集和问题:S={ x1 , x2 ,…, xn }是一个正整数的集合,c是一个正整数。子集和问题判定是否存在S的一个子集S1,使得s1中的各元素之和等于c。 最突出的事原创 2015-08-17 21:11:18 · 1873 阅读 · 0 评论 -
POJ 1141-Brackets Sequence(区间dp括号匹配打印路径)
题目地址:POJ 1141 题意:给出一串由‘(‘)’‘ [ ’ ’ ] ‘组成的串,将给出的括号序列以添加最小数目括号的形式进行配对。 思路:dp[i][j]表示当前子序列需要添加的最小字符数,path存储的是所有子问题的解。然后详情看代码解释。#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h原创 2015-08-17 11:24:54 · 1329 阅读 · 0 评论 -
POJ 2229-Sumsets(把n拆分为2的幂相加的拆分种数)
题目地址:POJ 2229 题意:给定一个正整数,求有多少种方法把它写成若干个2幂次的和 思路:可以用递推,对于一个整数n,分为奇数和偶数,我们应该分情况讨论。 1.如果为奇数,那么在这个表示中一定含有一个1,把这个1减去,就是n-1 即dp[n]=dp[n-1]。 2.如果为偶数,那么也分两种情况,有1和没1。对于有1的情况可以直接拆出两个1,然后变为n-2的情况。对于没有1的情况可以直原创 2015-08-27 21:09:06 · 3139 阅读 · 0 评论 -
HDU 5375(2015多校7)-Gray code(dp)
题目地址:HDU 5375 题意:给你一个二进制串,带’?’的位置可以由你来决定填’1’还是’0’,补充完整之后转换成格雷码表示,每一个位置都有一个权值a[i],只有格雷码为’1’的位可以加上权值,问你最终权值之和最大为多少。 思路:首先要明白二进制码和格雷码是如何转换的: dp[i][0]表示第i位为0的时候的最大值,dp[i][1]表示第i位为1的时候的最大值。对于第i位的最大值由dp[i原创 2015-08-12 11:29:26 · 1219 阅读 · 0 评论 -
SDUT 2857-艺术联合会(dp)
艺术联合会Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^题目描述艺术联合会顾名思义就是n个画家用n种颜色一起进行艺术创作(作画)。每一位画家仅使用一种颜色,并且规定n位画家使用的颜色是不同的,这里我们可以假设第一位画家使用的颜色编号为1,第2位画家使用的颜色编号为2以此类推。每一幅画上面都有原创 2015-02-03 14:45:32 · 1368 阅读 · 0 评论 -
POJ 1080-Human Gene Functions(dp)
Human Gene FunctionsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 17478 Accepted: 9732DescriptionIt is well known that a human gene can be conside原创 2015-02-03 16:44:54 · 1252 阅读 · 0 评论 -
POJ 1260-Pearls(dp)
PearlsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7573 Accepted: 3755DescriptionIn Pearlania everybody is fond of pearls. One company, called Th原创 2015-02-02 17:31:15 · 1081 阅读 · 0 评论 -
POJ 3267-The Cow Lexicon(dp_字符串)
The Cow LexiconTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8341 Accepted: 3941DescriptionFew know that the cows have their own dictionary with W原创 2015-02-02 11:31:09 · 1210 阅读 · 0 评论 -
POJ 2533-Longest Ordered Subsequence(dp_最长上升子序列)
Longest Ordered SubsequenceTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 35502 Accepted: 15572DescriptionA numeric sequence of ai is ordered if a1原创 2015-02-02 21:04:13 · 1243 阅读 · 0 评论 -
POJ 1836-Alignment(dp)
AlignmentTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 13624 Accepted: 4392DescriptionIn the army, a platoon is composed by n soldiers. During the原创 2015-02-02 09:03:38 · 1176 阅读 · 0 评论 -
UVA 10534-Wavio Sequence(dp_正序逆序最长上升子序列)
Wavio SequenceTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionProblem DWavio Sequence Input: Standard InputOutput: Standard Output原创 2015-01-29 19:20:16 · 1415 阅读 · 0 评论 -
POJ 1887-Testing the CATCHER(dp_最长下降子序列)
Testing the CATCHERTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 15382 Accepted: 5657DescriptionA military contractor for the Department of Defens原创 2015-01-29 14:14:38 · 740 阅读 · 0 评论 -
POJ 1159-Palindrome(dp_回文串+滚动数组)
PalindromeTime Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionA palindrome is a symmetrical string, that is, a string read identic原创 2015-01-29 09:10:57 · 1945 阅读 · 0 评论 -
POJ 1088-滑雪(dp)
滑雪Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 79309 Accepted: 29502DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上原创 2015-01-28 19:12:48 · 1129 阅读 · 0 评论 -
UVA 10100- Longest Match(dp之最长公共子序列)
题目地址:UVA 10100 题意:求两组字符串中最大的按顺序出现的相同单词数目。 思路:将字串中的连续的字母认作一个单词,依次计算出两个字符串中的单词,其中第1个字符串的单词序列为t1.word[1]…..t1.word[n],第2个字符串的单词序列为t2.word[1]…..t2.word[m]。然后将每个单词当成一个字符,使用LCS算法计算出两个字符串的最长公共子序列,该序列的长度就是最长原创 2015-08-18 19:59:48 · 1679 阅读 · 0 评论