随笔分类 -  dp

摘要:Problem Description Now here is a matrix with letter 'a','b','c','w','x','y','z' and you can change 'w' to 'a' or 'b', change 'x' to 'b' or 'c', chang 阅读全文
posted @ 2019-02-17 15:29 WAKBGAN 阅读(186) 评论(0) 推荐(0)
摘要:Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled with different qualities beans. Meantime, there i 阅读全文
posted @ 2019-02-17 14:27 WAKBGAN 阅读(345) 评论(0) 推荐(0)
摘要:众所周知,从20 ,21,...,2k-1这k个2的整数次幂中选出若干相加,可以表示出0~2k-1之前的任意整数 所以我可以把Ci个物品分解成p+2个 即若干个2的幂次方为系数的体积(对下面的这些体积进行0/1背包) 20*Vi+...+2p*Vi+Ri*Vi 阅读全文
posted @ 2019-02-16 23:22 WAKBGAN 阅读(1055) 评论(1) 推荐(0)
摘要:Problem Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some 阅读全文
posted @ 2019-02-16 22:04 WAKBGAN 阅读(176) 评论(0) 推荐(0)
摘要:Problem Description Pirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After 阅读全文
posted @ 2019-02-16 19:48 WAKBGAN 阅读(131) 评论(0) 推荐(0)
摘要:完美背包问题的模型如下: 给定N个物品,其中第i种物品的体积为Vi,价值为Wi,并且有无数个。有一个容积为M的背包,要求选择若干个物品放入背包,使得物品总体积不超过M的前提下,物品的价值总和最大。 我们可以像我们之前讨论0/1背包一样的考虑传统的二维dp方法https://www.cnblogs.c 阅读全文
posted @ 2019-02-16 14:54 WAKBGAN 阅读(172) 评论(0) 推荐(0)
摘要:0/1背包的问题模型如下: 给定N个物品,其中第i个物品的体积为Vi ,价值为Wi 。有一容积为M的背包,要选择一些物品放入背包,使物品体积不超过M的前提下,物品的价值总和最大。 dp[i][j]表示从前i个物品中选出了总体积为j的物品放入背包,物品的最大价值。即我们很容易得出解决的代码: 根据上面 阅读全文
posted @ 2019-02-16 14:45 WAKBGAN 阅读(204) 评论(0) 推荐(0)
摘要:链接:https://ac.nowcoder.com/acm/contest/369/A 题目描述 若你摘得小的星星 你将得到小的幸福 若你摘得大的星星 你将得到大的财富 若两者都能摘得 你将得到永远的愿望 摘星是罪孽的宽恕 摘星是夜晚的奇迹 抓住它吧 你所期望的那颗星 无法触及,因而耀眼 明明触及 阅读全文
posted @ 2019-02-15 22:57 WAKBGAN 阅读(277) 评论(0) 推荐(0)
摘要:Problem Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or grea 阅读全文
posted @ 2019-02-14 17:30 WAKBGAN 阅读(214) 评论(0) 推荐(0)
摘要:ST算法 在RMQ(区间最值问题)问题中,我了解到一个叫ST的算法,实质是二进制的倍增。 ST算法能在O(nlogn)的时间预处理后,用O(1)的时间在线回答区间最值。 f[i][j]表示从i位起的2^j个数中的最大(最小)数,即[i,i+2^j-1]中的最大(最小)值,从其定义中可以看出来。 下面 阅读全文
posted @ 2019-02-13 19:40 WAKBGAN 阅读(1320) 评论(0) 推荐(2)
摘要:Problem Description 最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经 阅读全文
posted @ 2019-02-13 19:20 WAKBGAN 阅读(163) 评论(0) 推荐(0)
摘要:Problem Description Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然 阅读全文
posted @ 2019-02-13 17:19 WAKBGAN 阅读(142) 评论(0) 推荐(0)
摘要:Problem Description Today is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC.A phalanx i 阅读全文
posted @ 2019-02-12 19:15 WAKBGAN 阅读(370) 评论(0) 推荐(1)
摘要:Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of m 阅读全文
posted @ 2019-02-12 16:17 WAKBGAN 阅读(271) 评论(0) 推荐(0)
摘要:Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ab 阅读全文
posted @ 2019-02-12 13:42 WAKBGAN 阅读(201) 评论(0) 推荐(0)