poj 1692(动态规划)】的更多相关文章

Crossed Matchings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2711   Accepted: 1759 Description There are two rows of positive integer numbers. We can draw one line segment between any two equal numbers, with values r, if one of them…
http://poj.org/problem?id=1692 这题看完题后就觉得我肯定不会的了,但是题解却很好理解.- - ,做题阴影吗 所以我还是需要多思考. 题目是给定两个数组,要求找出最大匹配数量. 匹配规则是: a[i] ==b[j],而且需要产生交叉,而且没对数只能匹配一次. 一开始的时候我被交叉吓到了,怎么判断交叉啊? 分析: 对于a[]的第i个数,b数组的第j个数,假设a[i] != b[j] 如果它能产生匹配,那么就需要, 对于a[i]这个数字,在b[]的前j - 1个找到和他数…
17-单调递增最长子序列 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:21 submit:49 题目描述: 求一个字符串的最长递增子序列的长度 如:dabdbf最长递增子序列就是abdf,长度为4 输入描述: 第一行一个整数0<n<20,表示有n个字符串要处理 随后的n行,每行有一个字符串,该字符串的长度不会超过10000 输出描述: 输出字符串的最长递增子序列的长度 样例输入: 复制 3 aaa ababc abklmncdefg 样例输…
思路:这是一道坑爹的动态规划,思路很容易想到,就是细节. 用dp[t][i][j],表示在第t时间,锤子停在(i,j)位置能获得的最大数量.那么只要找到一个点转移到(i,j)收益最大即可. #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #includ…
思路:简单动态规划 #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring> #include<iostream> #include<algorit…
用贪心简单证明之后就是一个从两头取的动态规划 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e3+9; int a[maxn],b[maxn]; int dp[maxn][maxn]; bool cmp(int a,int b) { return a>b; } int m…
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 42914 Accepted: 18914 Description A numeric sequence of ai is ordered if a1 < a2 < - < aN. Let the subsequence of the given numeric sequence (a1, a2, -, aN) be…
思路:每次枚举每个工人的右边界j,维护最优的左边界k.那么dp[j]=max(dp[j],dp[k]+(j-k)*w[i].p): 对于每个工人的初值k=w[i].s-1; 令x=j-w[i].l,如果(k-x)*w[i].p>dp[k]-dp[x],则k=x. #include<set> #include<map> #include<cmath> #include<queue> #include<cstdio> #include<v…
思路: 黑书的例题 #include<iostream> #include<cstring> #include<algorithm> #include<cmath> #include<cstdio> #define Maxn 210 using namespace std; int dp[Maxn][Maxn][Maxn],col[Maxn],len[Maxn],pre[Maxn],aper[Maxn],after[Maxn],vi[Maxn];…
思路:和黑书上的跳舞机类似 #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring> #include<iostream> #include<alg…
思路:黑书的例题 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define Maxn 1010 using namespace std; int dp[Maxn][Maxn],v[Maxn][Maxn]; char str[Maxn]; void Out(int s,int e) { if(s>e) return ; if(s==e) { ]==]…
滑雪 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道载一个 区域中最长底滑坡.区域由一个二维数组给出.数组的每个数字代表点的高度.下面是一个例子 1 2 3 4 5 16 17 18 19…
Description There are two rows of positive integer numbers. We can draw one line segment between any two equal numbers, with values r, if one of them is located in the first row and the other one is located in the second row. We call this line segmen…
#include <iostream> #include <string.h> using namespace std; ][];//存储当前位置能得到的最优解 ][];//存储当前位置的元素值 ][]={,,,,-,,,-};//四个方向,右,上,左,下 int N,M; int max(int a,int b) { return a>b?a:b; } int dp(int i,int j)//得到[i,j]位置的最优解 { ) return ans[i][j]; //寻找…
Milking Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7265   Accepted: 3043 Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤…
Function Run Fun Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17843   Accepted: 9112 Description We all love recursion! Don't we? Consider a three-parameter recursive function w(a, b, c): if a <= 0 or b <= 0 or c <= 0, then w(a, b…
我觉得好多套路我都不会ヘ(;´Д`ヘ) 题解拖到情人节后一天才完成,还有三场没补完,真想打死自己.( ˙-˙ ) A - 温泉旅店 UESTC - 878  题意 ​ 有n张牌,两人都可以从中拿出任意张,各自的得分为他们手中牌上的数字的异或和.求A的得分小于等于B的方案数. 题解: ​ DP,\(dp[i][j][k]\)表示前i张牌,使得A得分为j,B得分为k 的案数.\(dp[0][0][0]=1\) \[ dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j\wedge…
Coins Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 33998   Accepted: 11554 Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some…
此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276,1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈),1742, 1887, 1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975,…
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈), 1742, 1887,1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029,…
]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈), 1742, 1887, 1926(马尔科夫矩阵,求平 衡), 1936,1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029,2…
此文转载别人,希望自己可以做完这些题目. 1.POJ动态规划题目列表 easy:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276,1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈),1742, 1887, 1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975…
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 32923   Accepted: 19514 Description 73 88 1 02 7 4 44 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the hi…
动态规划与贪心相关: {HDU}{4739}{Zhuge Liang's Mines}{压缩DP} 题意:给定20个点坐标,求最多有多少个不相交(点也不相交)的正方形 思路:背包问题,求出所有的正方形,然后求最多有多少个正方形不互相覆盖,这题真是神思路. {POJ}{3846}{Mountain Road} 题意:给定两个地点车的班次,路是双向单车道,求安排最短的时间 思路:对车次序列进行二维DP转移,转移的时候需要注意时刻的维护.这个题目的DP思路是正向DP,每次遍历到f[i][j]都需要更新…
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098409.html 题目链接:poj 3783 Balls 动态规划 100层楼投鸡蛋问题 使用动态规划算法,使用$dp[i][j]$表示对于i层楼并拥有$j$个鸡蛋时能够判断鸡蛋质量需要的最少次数.假如我们在第$k$层扔下一个鸡蛋,则有两种情况,如果鸡蛋没有损坏则问题相当于我们对于$i-k$层楼拥有$j$个鸡蛋所需的最少的次数.如果鸡蛋损坏了,则问题相当于对于k层楼拥有$j-1$个鸡蛋…
题目链接:http://poj.org/problem?id=3181 题目大意:用1,2...K元的硬币,凑成N元的方案数. Sample Input 5 3 Sample Output 5 分析:这不是母函数是什么,不管你信不信,反正我是信了. 之前有过一篇,讲母函数的动态规划做法http://www.cnblogs.com/acm-bingzi/archive/2013/04/30/3051725.html 这道题目,坑就坑在高精度上了,刚开始怎么也没想到,而且做法也很奇特.就是将2个lo…
题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1033 http://poj.org/problem?id=1141 ZOJ目前挂了. 题目大意: 给一个括号序列,要求输出,最少增加括号数情况下,任意一个合法括号序列即可. 匹配是指()和[]完全合法,可以嵌套. 题目思路: [动态规划] 区间DP,枚举左右区间端点,两种匹配方法:中间拆开匹配或者直接头尾匹配. 转移得到最优值,同时记录得到最优值的方法,最后逆推得到不用增加的括号位置…
Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4522   Accepted: 1993 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually exp…
POJ 2152 fire / SCU 2977 fire(树型动态规划) Description Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so the governm…
POJ 3398 Perfect Service(树型动态规划,最小支配集) Description A network is composed of N computers connected by N − 1 communication links such that any two computers can be communicated via a unique route. Two computers are said to be adjacent if there is a com…