![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
OJ算法题目
Transcend2022
风帆
展开
-
DP(动态规划)背包问题
0-1背包问题 将一个容量为V的背包,物品有两个属性,一个w和一个v表示体积和属性值。每种物品只有一个。要求装下尽可能多,求最大价值。 转移状态方程: dp[j]=max(dp[dp[j-list[i].w]+list[i].v,dp[j-1]) #include #include using namespace std; struct E{ int w; int v; }lis原创 2017-12-15 20:58:39 · 206 阅读 · 0 评论 -
多包问题
#include #include #define INF 0x7fffffff using namespace std; struct E{ int w; int v; }list[2001]; int dp[10001]; int min(int a,int b) { return a<b?a:b; } int main() { int T; scanf("%d",原创 2017-12-15 21:32:15 · 656 阅读 · 0 评论 -
KMP算法很强势的解释
一:背景转自(https://segmentfault.com/a/1190000008575379)给定一个主串(以 S 代替)和模式串(以 P 代替),要求找出 P 在 S 中出现的位置,此即串的模式匹配问题。Knuth-Morris-Pratt 算法(简称 KMP)是解决这一问题的常用算法之一,这个算法是由高德纳(Donald Ervin Knuth)和沃恩·普拉特在1974年构思,同年詹姆...转载 2018-04-25 21:05:43 · 451 阅读 · 0 评论 -
POJ1358解析
Description The Ministry of housing is planning a huge construction project of several housing complexes. Each complex includes several apartments to be sold to government employees at reasonable pri...原创 2018-07-25 12:15:56 · 304 阅读 · 0 评论