动态规划
棉毛裤穿吗
而我们终将回归那片太初的花海
展开
-
6.2 PAT 甲级 1068 Find More Coins
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for eac原创 2020-06-02 19:01:11 · 127 阅读 · 0 评论 -
5.22 PAT 甲级 1045 Favorite Color Stripe
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe. It is said原创 2020-05-22 17:32:27 · 117 阅读 · 0 评论 -
5.22 PAT 甲级 1007 Maximum Subsequence Sum
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For exampl...原创 2020-05-22 08:59:33 · 112 阅读 · 0 评论 -
4.12 背包问题总结
01背包问题和完全背包问题在https://blog.csdn.net/qq_39782006/article/details/105420831 多重背包问题 有N种物品和一个容量是V的背包。 第i种物品最多有 si件,每件体积是 vi,价值是 wi。 求解将哪些物品装入背包,可使物品体积总和不超过背包容量,且价值总和最大。 输出最大价值。 输入格式 第一行两个整...原创 2020-04-12 15:57:09 · 71 阅读 · 0 评论 -
4.9-4.11 闫氏dp分析法
那啥 写这篇只是想总结一下白天听课的成果。 强推一个up 大雪菜 一开始就是找一个什么算法的时候搜到这个up的视频,后来发现这个up讲东西讲的特别清楚,而且是他是真的牛逼,还有自己的网站 Acwing,里面可以刷题啊之类的,还有很多课很多活动啥啥的······多厉害不讲了,回到这里,我听的课是https://www.bilibili.com/video/BV1X741127ZM?t=2703...原创 2020-04-09 22:42:37 · 309 阅读 · 0 评论 -
3.19 动态规划专题【上】(参考《算法笔记》)
1.最大连续子序列和 给定一个数字序列:A1,A2······An,求i,j(1<=i<=j<=n)使得Ai+······+Aj最大,输出这个最大和。 Sample Input 6 -2 11 -4 13 -5 -2 Sample Output 20 用dp[i]表示从A1到Ai最大连续子序列和,必须是以Ai为结尾的,也就是必须加上Ai。 因为是要连续的序列,所以...原创 2020-03-19 21:16:17 · 112 阅读 · 1 评论 -
2.24 [hduoj] 2082 找单词【背包/动态规划】
Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26。那么,对于给定的字母,可以找到多少价值<=50的单词呢?单词的价值就是组成一个单词的所有字母的价值之和,比如,单词ACM的价值是1+3+14=18,单词HDU的价值是8+4+21=33。(组成的单词与排列顺序无关...原创 2020-02-24 21:07:37 · 197 阅读 · 0 评论 -
▲▲▲2.8 [hduoj] 2062 Subset sequence【俺还莫得搞明白】【可以用dp】
Problem Description Consider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lex...原创 2020-02-08 16:37:47 · 112 阅读 · 0 评论 -
2.8 [hduoj] 2084 数塔【动态规划】
Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗? Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表...原创 2020-02-08 15:42:56 · 156 阅读 · 0 评论