
动态规划
文章平均质量分 80
linyuxilu
我没有什么追求,只希望自己和关心我的家人和朋友都可以幸福!
展开
-
HDU1231 最大连续子序列(LCS)
最大连续子序列 HDU - 1231 分析:注意:若所有K个元素都是负数,则定义其最大和为0,输出整个序列的首尾元素。#includeint t,n,v[100010],a,b,m;int f(int v[] ){ int c=0,d=1,i; for(i=0; i<t; i++) { c+=v[i];//累加连续和原创 2017-04-11 17:52:06 · 292 阅读 · 0 评论 -
AYITACM2016省赛第三周 C-妥协(最长公共单词序列)
In a few months the European Currency Union will become a reality. However, to join the club, theMaastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except原创 2016-05-04 19:09:48 · 397 阅读 · 0 评论 -
AYITACM2016省赛第三周 G - Unidirectional TSP(DP单向旅行商问题)
DescriptionBackgroundProblems that require minimum paths through some domain appear in many different areas of computer science. For example, one of the constraints in VLSI routing probl原创 2016-05-03 17:23:24 · 618 阅读 · 0 评论 -
AYITACM2016省赛第三周 J - Longest Run on a Snowboard(dp记忆化搜索)
Michael likes snowboarding. That’s not very surprising, since snowboarding is really great. The badthing is that in order to gain speed, the area must slide downwards. Another disadvantage is that w原创 2016-05-03 11:33:04 · 289 阅读 · 0 评论 -
AYITACM2016省赛第三周 B-递增递减子序列(dp+二分)
Wavio is a sequence of integers. It has some interesting properties.• Wavio is of odd length i.e. L = 2 ∗ n + 1.• The first (n + 1) integers of Wavio sequence makes a strictly increasing sequence.原创 2016-05-03 09:04:10 · 357 阅读 · 0 评论 -
AYITACM2016省赛第三周D-max sum(DP最大字段和)
DescriptionGiven 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-05-02 17:03:52 · 529 阅读 · 0 评论 -
AYITACM2016省赛第三周A-Nested Dolls(贪心解嵌套问题)
DescriptionDilworth is the world’s most prominent collector of Russian nested dolls: he literally has thousands of them! You know, the wooden hollow dolls of different sizes of which the small原创 2016-05-02 16:52:01 · 454 阅读 · 0 评论 -
Best Coder 1003 string(dp)
DescriptionThere is a string S.S only contain lower case English character.(10 \leq length(S) \leq 1,000,000) How many substrings there are that contain at least k(1 \leq k \leq 26) distin原创 2016-04-29 08:10:59 · 304 阅读 · 0 评论 -
AYIT606第四周周六赛 C - Audiophobia 音频恐惧症(dp)
C - Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not hav原创 2016-04-21 11:28:12 · 408 阅读 · 0 评论 -
AYITACM2016省赛第二周 I 分硬币(01背包)
DescriptionIt's commonly known that the Dutch have invented copper-wire. Two Dutch men were fighting over a nickel, which was made of copper. They were both so eager to get it and the figh原创 2016-04-26 17:16:33 · 476 阅读 · 0 评论 -
AYITACM2016省赛第二周 G - History Grading历史评分(最长公共子序列)
DescriptionBackgroundMany problems in Computer Science involve maximizing some measure according to constraints.Consider a history exam in which students are asked to put several histori原创 2016-04-26 16:05:10 · 402 阅读 · 0 评论 -
AYITACM2016省赛第二周 H(最长公共子序列)
InputInput consists of pairs of lines. The first line of a pair contains the first string and the second linecontains the second string. Each string is on a separate line and consists of at most 1,0原创 2016-04-26 14:10:25 · 371 阅读 · 0 评论 -
AYITACM2016省赛第二周E - Cleaning Shifts(区间覆盖)
DescriptionFarmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divide原创 2016-04-26 12:56:31 · 1720 阅读 · 2 评论 -
AYITACM2016省赛第二周(dp+其他)B-做作业(贪心)
DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in th原创 2016-04-26 11:06:19 · 376 阅读 · 0 评论 -
AYITACM2016省赛第二周 D-今年暑假不AC(选择不相交区间)
Description“今年暑假不AC?” “是的。” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&*%...” 确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。 作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级原创 2016-04-26 09:06:19 · 320 阅读 · 0 评论 -
AYITACM2016省赛第三周H - Let Me Count The Ways(递推)
DescriptionAfter making a purchase at a large department store, Mel's change was 17 cents. He received 1 dime, 1 nickel, and 2 pennies. Later that day, he was shopping at a convenience store.原创 2016-05-04 21:09:56 · 308 阅读 · 0 评论 -
AYITACM2016省赛第三周F - Cutting Sticks(切木头,区间电dp合并)
You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery,Inc. (ACM), charges money according to the length of the stick being cut. Their procedure of work原创 2016-05-04 21:39:42 · 491 阅读 · 0 评论 -
AYITACM2016省赛第三周 L - 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 superviso原创 2016-05-06 14:40:29 · 511 阅读 · 0 评论 -
HDU 1503 Advanced Fruits (LCS最长公共子序列)
The company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn't work, but sometime原创 2017-04-11 17:48:46 · 255 阅读 · 0 评论 -
HDU1087 超级跳跃(递增子序列最大和)
Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 36107 Accepted Submission(s): 16464Problem Descri原创 2017-02-27 20:35:20 · 2286 阅读 · 0 评论 -
hdu 1171 Big Event in HDU(01背包变形)
题目描述Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College原创 2016-08-03 11:44:43 · 351 阅读 · 0 评论 -
多重背包(动态规划)
题目B 剁手党 限时:2000ms剁手党们整天游荡在各种大小商场,有N种物品,每种物品的数量为C1,C2......Cn。从中任选若干件放在容量为W的背包里,每种物品的体积为W1,W2......Wn(Wi为整数),与之相对应的价值为P1,P2......Pn(Pi为整数)。求背包能够容纳的最大价值。 输原创 2016-05-25 21:46:28 · 534 阅读 · 0 评论 -
HDU - 3466 Proud Merchants骄傲的商人(01背包变形)
DescriptionRecently, 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原创 2016-08-02 22:12:36 · 587 阅读 · 0 评论 -
POJ - 1042 Gone Fishing(钓鱼)(深搜+贪心)
DescriptionJohn is going on a fishing trip. He has h hours available (1 <= h <= 16), and there are n lakes in the area (2 <= n <= 25) all reachable along a single, one-way road. John starts at l原创 2016-07-22 09:49:42 · 3238 阅读 · 0 评论 -
Robberies小偷(01背包变形)
题目描述The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the原创 2016-08-05 09:26:15 · 438 阅读 · 0 评论 -
nyoj 716 River Crossing(dp)
River Crossing 时间限制:1000 ms | 内存限制:65535 KB 难度:4描述Afandi is herding N sheep across the expanses of grassland when原创 2016-05-21 11:27:56 · 347 阅读 · 0 评论 -
nyoj 715相邻的计数(dp)
Adjacent Bit Counts 时间限制:1000 ms | 内存限制:65535 KB 难度:4描述For a string of n bits x1, x2, x3, …, xn, the adjacent bit count原创 2016-05-20 21:46:51 · 278 阅读 · 0 评论 -
nyoj 309 乘雪橇(模拟)
BOBSLEDDING时间限制:1000 ms | 内存限制:65535 KB难度:3描述Dr.Kong has entered a bobsled competition because he hopes his hefty weight will give his an advantage over the L meter course原创 2016-05-19 21:09:34 · 341 阅读 · 0 评论 -
AYIT2016省赛集训第五周H - String to Palindrome(dp)
In this problem you are asked to convert a string into a palindrome with minimum number of operations. The operations are described below:Here you’d have the ultimate freedom. You are allowed to:原创 2016-05-18 21:34:34 · 248 阅读 · 0 评论 -
nyoj 251 有趣的竞选(STL vector容器)
AMAZING AUCTION时间限制:3000 ms | 内存限制:65535 KB难度:4描述Recently the auction house has introduced a new type of auction, the lowest price auction. In this new system, people compete for the l原创 2016-05-05 14:34:19 · 272 阅读 · 0 评论 -
AYITACM2016省赛第三周I - Optimal Array Multiplication Sequence(dp)
矩阵最少乘法题意:给你2个矩阵A、B,我们使用标准的矩阵相乘定义C=AB如下:A阵列中栏(column)的数目一定要等于B阵列中列(row)的数目才可以做此2阵列的相乘。若我们以rows(A),columns(A)分别代表A阵列中列及栏的数目,要计算C阵列共需要的乘法的数目为:rows(A)*columns(B)*columns(A)。例如:A阵列是一个原创 2016-05-06 21:56:06 · 547 阅读 · 0 评论 -
AYITACM2016省赛第三周M - Beijing Guards(贪心+二分)
Beijing was once surrounded by four rings of city walls: the Forbidden City Wall, the Imperial CityWall, the Inner City Wall, and finally the Outer City Wall. Most of these walls were demolished in原创 2016-05-06 17:22:10 · 740 阅读 · 0 评论 -
AYITACM2016省赛第二周(dp+其他) A-雷达装置(区间选点问题)
DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar install原创 2016-04-25 21:50:27 · 381 阅读 · 0 评论 -
蓝桥杯 历届试题 逆波兰表达式
逆波兰表达式 正常的表达式称为中缀表达式,运算符在中间,主要是给人阅读的,机器求解并不方便。 例如:3 + 5 * (2 + 6) - 1 而且,常常需要用括号来改变运算次序。 相反,如果使用逆波兰表达式(前缀表达式)表示,上面的算式则表示为: - + 3 * 5 + 2 6 1 不再需要括号,机器可以用递归的方法很方便地求解。原创 2016-03-17 19:53:29 · 863 阅读 · 0 评论 -
蓝桥杯 历届试题 打印大X
打印大X小明希望用星号拼凑,打印出一个大X,他要求能够控制笔画的宽度和整个字的高度。为了便于比对空格,所有的空白位置都以句点符来代替。要求输入两个整数m n,表示笔的宽度,X的高度。用空格分开(0要求输出一个大X例如,用户输入:3 9程序应该输出:***.....***.***...***...***.***.....*****.......**原创 2016-03-17 19:44:42 · 1309 阅读 · 0 评论 -
暑假集训第二周——递推 汉诺塔系列问题
/先说汉若塔I(经典汉若塔问题),有三塔,A塔从小到大从上至下放有N个盘子,现在要搬到目标C上,规则小的必需放在大的上面,每次搬一个,求最小步数。这个问题简单,DP:a[n]=a[n-1]+1+a[n-1],先把上面的n-1个放在B上,把最大的放在目标C上,再把N-1个放回到C上即可B - 汉诺塔IITime Limit:1000MS Memory原创 2015-07-21 09:28:34 · 966 阅读 · 0 评论 -
暑假集训第四周 DP D - Big Event in HDU 分院
D - Big Event in HDUTime Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionNowadays, we all know that Computer College is the biggest d原创 2015-08-03 21:41:26 · 342 阅读 · 0 评论 -
暑假集训第四周 DP C - Proud Merchants
C - Proud MerchantsTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionRecently, iSea went to an ancient country. For such a long ti原创 2015-08-03 21:33:11 · 329 阅读 · 0 评论 -
暑假集训第四周 阶段一 DP 动态规划 B - Bone Collector
B - Bone CollectorDescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , al原创 2015-08-03 19:39:38 · 415 阅读 · 0 评论 -
暑假集训第二周——递推 骆驼猜名字
T - 骆驼猜名字Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescription今年暑假杭电ACM集训队第一次组成女生队,其中有一队叫RPG,但做为集训队成员之一的野骆驼竟然不知道RPG三个人具体是谁谁。RPG给他机会让他猜猜原创 2015-07-22 21:42:21 · 664 阅读 · 0 评论