————动态规划————
1
BigZong
这个作者很懒,什么都没留下…
展开
-
动态规划——背包问题
首先是背包问题: 1、01背包 要想计算某一条路径的值的和的最大值,就需要对每一个节点处的不同值进行分析,取大舍小,然后相加,简单地来说就是加与不加。 在01背包问题中,也只有两种选择方式,放或者不放。 下面我就先给一个公式:f(i,v)=max{f(i-1,v),f(i-1,v-weight[i])+w[i]} 在这个式子中,前面的一部分代表不放,那么我就可以说是 前i-1个...原创 2018-12-28 12:09:51 · 118 阅读 · 0 评论 -
I NEED A OFFER!
Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能性b。不同学校之...原创 2019-01-13 16:08:04 · 168 阅读 · 0 评论 -
Common Subsequence-最长公共子序列
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a sub...原创 2019-01-14 15:35:17 · 142 阅读 · 0 评论 -
POJ 1579 Function Run Fun
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, c) returns: 1 if a > 20 or b > 20 or c > 20...原创 2019-01-15 08:21:25 · 162 阅读 · 0 评论 -
Employment Planning
A project manager wants to determine the number of the workers needed in every month. He does know the minimal number of the workers needed in each month. When he hires or fires a worker, there will b...原创 2019-01-15 10:42:29 · 535 阅读 · 0 评论 -
★DP-路径记录
FatMouse's Speed 题意:很多肥老鼠认为,长的越肥,奔跑速度就越快,为了反驳这个观点,你现在需要对老鼠的体重和速度进行研究,你要在老鼠序列中找出一个子序列,使得老鼠的体重在增加,但是速度却在减慢 Input 输入以eof结束。输入中每行有两个正整数,分别表示老鼠的体重和速度,范围均在1到10000之间,输入数据最多有1000只老鼠。某些老鼠可能有相同的体重,某些老鼠可能有...原创 2019-01-15 17:01:21 · 532 阅读 · 0 评论 -
Pascal's Travels
An n x n game board is populated with integers, one nonnegative integer per square. The goal is to travel along any legitimate path from the upper left corner to the lower right corner of the board. T...原创 2019-01-15 21:09:05 · 176 阅读 · 0 评论 -
HDU 5074 Hatsune Miku
题目链接: HDU 5074 题意: 给定一个大小为m*m的矩阵,score(ai, ai+1)代表矩阵ai行ai+1列对应的值,现在给出n行数字,如果这个数字a[i]为-1,那这个数字就可以取1到m中的任意数,反之则不能,现在让找出score(ai, ai+1)和的最大值。 题解: 我们知道,如果说输入的n个数没有一个-1的话,这些数据就是固定值了,可以直接加起来 而如果现在...原创 2019-04-06 15:07:38 · 174 阅读 · 0 评论 -
数位dp总结 之 从入门到模板
转自:https://blog.csdn.net/wust_zzwh/article/details/52100392 基础篇 数位dp是一种计数用的dp,一般就是要统计一个区间[le,ri]内满足一些条件数的个数。所谓数位dp,字面意思就是在数位上进行dp咯。数位还算是比较好听的名字,数位的含义:一个数有个位、十位、百位、千位......数的每一位就是数位啦! 之所以要引入数位的概念完全就是...转载 2019-04-02 15:08:39 · 137 阅读 · 0 评论 -
Monkey and Banana
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...原创 2019-01-12 21:46:28 · 111 阅读 · 0 评论 -
最长递增子序列问题---动态规划
对于最长递增子序列 递推方程的意思是,在求以ai为末元素的最长递增子序列时,找到所有序号在L前面且小于ai的元素aj,即j<i且aj<ai。如果这样的元素存在,那么对所有aj,都有一个以aj为末元素的最长递增子序列的长度f(j),把其中最大的f(j)选出来,那么f(i)就等于最大的f(j)加上1,即以ai为末元素的最长递增子序列,等于以使f(j)最大的那个aj为末元素的递增子序列最末...原创 2019-01-07 16:47:54 · 795 阅读 · 0 评论 -
289-苹果-nyist-动态规划之01背包问题
题目描述: 李永哲有n个苹果,要将它放入容量为v的背包。给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值。 输入描述: 有多组测试数据,每组测试数据第一行为2个正整数,分别代表苹果的个数n和背包的容量v,n、v同时为0时结束测试,此时不输出。接下来的n行,每行2个正整数,用空格隔开,分别代表苹果的大小c和价钱w。所有输入数字的范围大于等于0,小于等于1000。 输出描...原创 2018-12-28 15:05:13 · 117 阅读 · 0 评论 -
POJ1163-The Triangle
Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts...原创 2018-12-29 09:59:23 · 184 阅读 · 0 评论 -
完全背包之饭卡
电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Input 多组数据。对于每组数据: 第一行为正整数...原创 2018-12-31 10:54:46 · 109 阅读 · 0 评论 -
HDU 1257-最少拦截系统&&POJ 2533
动态规划类型:多少个最长递增数列填满一串数。 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就...原创 2019-01-10 20:36:59 · 114 阅读 · 0 评论 -
动态规划-01背包之-Proud Merchants
Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud even if their ...原创 2019-01-01 10:09:39 · 272 阅读 · 0 评论 -
动态规划-完全背包之-Investment
John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only i...原创 2019-01-01 11:57:02 · 176 阅读 · 0 评论 -
背包九讲
转载:dd_engi 的背包九讲 目录 第一讲 01背包问题 第二讲 完全背包问题 第三讲 多重背包问题 第四讲 混合三种背包问题 第五讲 二维费用的背包问题 第六讲 分组的背包问题 第七讲 有依赖的背包问题 第八讲 泛化物品 第九讲 背包问题问法的变化 附:USACO中的背包问题 前言 本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个...转载 2019-01-01 16:50:55 · 337 阅读 · 0 评论 -
Dividing-动态规划之多重背包
Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same ...原创 2019-01-01 16:55:10 · 505 阅读 · 1 评论 -
HDU - 4722 Good Numbers(数位DP)
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5969Accepted Submission(s): 1886 题目链接: HDU - 4722 题目描述: 输入两个数A,B,判断从A到B之间有多少个数的各个位数上数字...原创 2019-04-02 16:29:45 · 196 阅读 · 0 评论