动态规划
BYSora
这个作者很懒,什么都没留下…
展开
-
poj1163——The Triangle(简单dp)
Description7 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 at原创 2017-05-03 11:39:34 · 1080 阅读 · 0 评论 -
Lightoj1205——Palindromic Numbers(数位dp+回文数)
A palindromic number or numeral palindrome is a ‘symmetrical’ number like 16461 that remains the same when its digits are reversed. In this problem you will be given two integers i j, you have to find原创 2016-09-26 19:27:31 · 1965 阅读 · 0 评论 -
hdu3555——Bomb(数位dp)
Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current原创 2016-09-21 20:48:17 · 600 阅读 · 0 评论 -
hdu2089——不要62(数位dp)
Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6和2原创 2016-09-21 19:45:41 · 520 阅读 · 0 评论 -
hdu3652——B-number(数位dp变形)
Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string “13” and can be divided by 13. For example, 130 and 2613 are wqb-numbers,原创 2016-09-21 21:03:02 · 372 阅读 · 0 评论 -
uva11456——Trainsorting(LIS)
Erin is an engineer. She drives trains. She also arranges the cars within each train. She prefers to put the cars in decreasing order of weight, with the heaviest car at the front of the train.Unfortun原创 2016-09-08 19:45:02 · 925 阅读 · 0 评论 -
Lightoj1068——Investigation(数位dp)
An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is divisible by 3 and 12 (3+7+0+2) is also divisible by 3. This property also holds for the integer 9.In原创 2016-09-23 21:53:52 · 706 阅读 · 0 评论 -
poj3252——Round Numbers(数位dp)
DescriptionThe cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone’ (also known as ‘Rock, Paper, Scissors’, ‘Ro, Sham, Bo’, and a host of other names) in ord原创 2016-09-23 21:00:24 · 976 阅读 · 0 评论 -
Lightoj1032——Fast Bit Calculations(数位dp)
A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as “true” or “false” respectively). And every decimal number has a binary representation which is actually a series of原创 2016-09-23 20:15:39 · 682 阅读 · 0 评论 -
Lightoj1140——How Many Zeroes?(数位dp)
Jimmy writes down the decimal representations of all natural numbers between and including m and n, (m ≤ n). How many zeroes will he write down?Input Input starts with an integer T (≤ 11000), denoting原创 2016-09-23 18:38:59 · 371 阅读 · 0 评论 -
hdu3709——Balanced Number(数位dp)
Problem Description A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the dig原创 2016-09-23 18:13:02 · 318 阅读 · 0 评论 -
hdu1009——FatMouse' Trade
Problem DescriptionFatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room con原创 2015-05-28 21:58:51 · 649 阅读 · 0 评论 -
hdu2037——今年暑假不AC
Problem Description“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、原创 2015-06-08 20:48:41 · 591 阅读 · 0 评论 -
hdu1050——Moving Tables
Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north sid原创 2015-06-08 21:08:01 · 548 阅读 · 1 评论 -
hdu1003——Max Sum(在线算法+求起点终点)
Problem Description Given a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 =原创 2016-11-18 19:03:28 · 820 阅读 · 0 评论 -
hdu1087——Super Jumping! Jumping! Jumping!(最大递增子序列和)
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you原创 2016-11-18 21:20:14 · 647 阅读 · 0 评论 -
poj1088——滑雪(记忆化dp)
DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813原创 2017-04-19 14:56:14 · 790 阅读 · 0 评论 -
蓝桥杯算法提高——概率计算(概率dp)
问题描述 生成n个∈[a,b]的随机整数,输出它们的和为x的概率。 输入格式 一行输入四个整数依次为n,a,b,x,用空格分隔。 输出格式 输出一行包含一个小数位和为x的概率,小数点后保留四位小数 样例输入 2 1 3 4 样例输出 0.3333 数据规模和约定 对于50%的数据,n≤5. 对于100%的数据,n≤100,b≤100.#include <i原创 2017-04-05 16:17:59 · 1368 阅读 · 1 评论 -
Lightoj1047——Neighbor House(dp)
The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They’ve also decided that no two neighboring houses will be painted the same color. The neighbors of house i ar原创 2017-04-12 20:10:03 · 821 阅读 · 0 评论 -
hdu1520——Anniversary party(树形dp)
Problem Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor原创 2017-04-01 19:59:29 · 704 阅读 · 0 评论 -
poj2342——Anniversary party(树形dp)
DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation原创 2017-03-31 21:24:33 · 538 阅读 · 0 评论 -
蓝桥杯算法提高——拿糖果(数学+dp)
问题描述 妈妈给小B买了N块糖!但是她不允许小B直接吃掉。 假设当前有M块糖,小B每次可以拿P块糖,其中P是M的一个不大于根号下M的质因数。这时,妈妈就会在小B拿了P块糖以后再从糖堆里拿走P块糖。然后小B就可以接着拿糖。 现在小B希望知道最多可以拿多少糖。 输入格式 一个整数N 输出格式 最多可以拿多少糖 样例输入 15 样例输出 6 数据规模和约定原创 2017-03-31 15:30:21 · 1270 阅读 · 0 评论 -
蓝桥杯历届试题——最大子阵(矩阵在线算法)
问题描述 给定一个n*m的矩阵A,求A中的一个非空子矩阵,使这个子矩阵中的元素和最大。 其中,A的子矩阵指在A中行和列均连续的一块。 输入格式 输入的第一行包含两个整数n, m,分别表示矩阵A的行数和列数。 接下来n行,每行m个整数,表示矩阵A。 输出格式 输出一行,包含一个整数,表示A中最大的子矩阵中的元素和。 样例输入 3 3 -1 -4 3 3 4 -1原创 2017-03-14 18:53:42 · 1333 阅读 · 0 评论 -
蓝桥杯历届试题——翻硬币(贪心)
问题描述 小明正在玩一个“翻硬币”的游戏。桌上放着排成一排的若干硬币。我们用 * 表示正面,用 o 表示反面(是小写字母,不是零)。比如,可能情形是:**oo***oooo如果同时翻转左边的两个硬币,则变为:oooo***oooo现在小明的问题是:如果已知了初始状态和要达到的目标状态,每次只能同时翻转相邻的两个硬币,那么对特定的局面,最少要翻动多少次呢?我们约定:把翻动相邻的两个硬币叫做一步操作,原创 2017-03-07 21:17:38 · 737 阅读 · 0 评论 -
蓝桥杯历届试题——地宫取宝 (记忆化dp)
问题描述 X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。 地宫的入口在左上角,出口在右下角。 小明被带到地宫的入口,国王要求他只能向右或向下行走。 走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。 当小明走到出口时,如果他手中的宝贝恰好是k件,则这些宝贝就可以送给小明。 请你帮原创 2017-03-10 14:39:30 · 807 阅读 · 0 评论 -
poj3616——Milking Time(dp最大子序列)
DescriptionBessie 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 ≤ 1,000,000) hours (conveniently labeled 0..N-1) s原创 2016-11-23 20:53:52 · 876 阅读 · 0 评论 -
poj3186——Treats for the Cows(区间dp)
DescriptionFJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a giv原创 2016-11-21 21:25:57 · 692 阅读 · 0 评论 -
hdu1257——最少拦截系统(贪心)
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救原创 2016-11-20 21:08:30 · 1031 阅读 · 0 评论 -
hdu1176——免费馅饼(简单dp)
Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身原创 2016-11-20 20:19:44 · 880 阅读 · 0 评论 -
hdu2187——悼念512汶川大地震遇难同胞——老人是真饿了(贪心)
对于幸存的灾民来说,最急待解决的显然是温饱问题,救灾部队一边在组织人员全力打通交通,一边在组织采购粮食。现在假设下拨了一定数量的救灾经费要去市场采购大米(散装)。如果市场有m种大米,各种大米的单价和重量已知,请问,为了满足更多灾民的需求,最多能采购多少重量的大米呢?Input输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(0Out原创 2015-06-10 21:00:31 · 799 阅读 · 0 评论 -
hdu4508——湫湫系列故事——减肥记I(背包)
Problem Description 对于吃货来说,过年最幸福的事就是吃了,没有之一! 但是对于女生来说,卡路里(热量)是天敌啊! 资深美女湫湫深谙“胖来如山倒,胖去如抽丝”的道理,所以她希望你能帮忙制定一个食谱,能使她吃得开心的同时,不会制造太多的天敌。 当然,为了方便你制作食谱,湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增原创 2015-06-28 16:41:20 · 929 阅读 · 0 评论 -
poj1458——Common Subsequence(最长公共子序列)
DescriptionA 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 subseq原创 2016-05-27 20:30:37 · 399 阅读 · 0 评论 -
poj1837——Balance(dp)
DescriptionGigel has a strange “balance” and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm’s length is原创 2016-04-19 21:42:09 · 425 阅读 · 0 评论 -
poj2479——Maximum sum(dp)
DescriptionGiven a set of n integers: A={a1, a2,…, an}, we define a function d(A) as below: Your task is to calculate d(A). InputThe input consists of T(<=30) test cases. The number of test cases (原创 2016-05-03 15:38:20 · 530 阅读 · 0 评论 -
poj2955——Brackets(区间dp)
DescriptionWe give the following inductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence, if s is a regular brackets sequence, then (s) and [s] are regu原创 2016-05-13 17:00:51 · 471 阅读 · 0 评论 -
hdu4745——Two Rabbits(区间dp,最长回文子序列)
Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon, they planned to play a game with some stones. There were n stones on the ground and they w原创 2016-05-13 10:35:08 · 711 阅读 · 0 评论 -
hdu3555——Bomb(数位dp)
Description The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number原创 2016-04-29 21:06:01 · 567 阅读 · 0 评论 -
Lightoj1227——Boiled Eggs(贪心)
Three of the trouble-makers went to Malaysia this year. A rest house was booked for them. Unlike other rest houses, this rest house was like a normal duplex house. So, ithad a kitchen. And the troub原创 2016-04-16 18:04:05 · 510 阅读 · 0 评论 -
hdu4283——You Are the One(区间dp)
Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it a原创 2016-04-27 16:56:03 · 863 阅读 · 0 评论 -
hdu1114——Piggy-Bank(完全背包求最小价值)
Problem Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The i原创 2016-04-13 15:37:02 · 572 阅读 · 0 评论