
动态规划
文章平均质量分 84
mrcoderrev
C
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
第九届国赛B组
标题:搭积木小明对搭积木非常感兴趣。他的积木都是同样大小的正立方体。在搭积木时,小明选取 m 块积木作为地基,将他们在桌子上一字排开,中间不留空隙,并称其为第0层。随后,小明可以在上面摆放第1层,第2层,……,最多摆放至第n层。摆放积木必须遵循三条规则:规则1:每块积木必须紧挨着放置在某一块积木的正上方,与其下一层的积木对齐;规则2:同一层中的积木必须连续摆放,中间不能留有空隙;规则3...原创 2019-05-21 11:12:11 · 173 阅读 · 0 评论 -
51 nod 1354 选数字(stl+dp)
1354 选数字基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注当给定一个序列a[0],a[1],a[2],...,a[n-1] 和一个整数K时,我们想找出,有多少子序列满足这么一个条件:把当前子序列里面的所有元素乘起来恰好等于K。样例解释:对于第一个数据,我们可以选择[3]或原创 2017-09-18 17:38:14 · 416 阅读 · 0 评论 -
51 nod 1503 猪和回文(双线程DP)
1503 猪和回文题目来源: CodeForces基准时间限制:2 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注一只猪走进了一个森林。很凑巧的是,这个森林的形状是长方形的,有n行,m列组成。我们把这个长方形的行从上到下标记为1到n,列从左到右标记为1到m。处于第r行第c列的格子用(r,c)表示。原创 2017-09-15 23:44:56 · 230 阅读 · 0 评论 -
hdu 6199 gems gems gems(DP)
gems gems gemsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1518 Accepted Submission(s): 349Problem DescriptionNow there ar原创 2017-09-15 20:18:48 · 267 阅读 · 1 评论 -
hiho 1580 Matrix(dp 降维压缩)
#1580 : Matrix时间限制:1000ms单点时限:1000ms内存限制:256MB描述Once upon a time, there was a little dog YK. One day, he went to an antique shop and was impressed by a beautiful picture.原创 2017-09-24 13:37:39 · 260 阅读 · 0 评论 -
hdu 6170 Two strings(DP)
Two stringsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 855 Accepted Submission(s): 338Problem DescriptionGiving two strin原创 2017-08-23 11:03:33 · 359 阅读 · 0 评论 -
hdu 6149 Valley Numer II(状压+ 枚举)
Valley Numer IITime Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 310 Accepted Submission(s): 101Problem Description众所周知,度度熊非常喜原创 2017-08-20 17:31:37 · 470 阅读 · 0 评论 -
hdu 6146 Pokémon GO(DP)
Pokémon GOTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 275 Accepted Submission(s): 159Problem Description众所周知,度度熊最近沉迷于 Pok原创 2017-08-20 16:05:10 · 433 阅读 · 0 评论 -
bibreoj #6191. 「美团 CodeM 复赛」配对游戏(DP)@
#6191. 「美团 CodeM 复赛」配对游戏内存限制:256 MiB时间限制:1000 ms标准输入输出题目类型:传统评测方式:文本比较上传者: April_AA提交提交记录统计测试数据附加文件题目描述有 nnn 个人排成一排,一开始全部面向前方,然后随机朝左或是朝右转。然后我们不断审查这个队列,每次选择两个面原创 2017-07-28 08:57:09 · 580 阅读 · 0 评论 -
LA 3695 Garbage Heap (DP)
题意:给出平面上的N个点,找一个矩形使得边界上的点最多解:选定上下边界,枚举左右边界;left[i],i边的左边有多少被包含在上下边界上的点,on[i]i边有多少被包含在上下边界上的点(不包括上下边界),on2[i]包括上下边界;ans=left[j]-left[i]+on2[j]+on[i]; 当枚举右边界时,保留最优值on[i]-left[i],#inc原创 2017-07-24 18:03:12 · 270 阅读 · 0 评论 -
LA 3029 City Game (DP||单调栈)
City Gamehttp://acm.hdu.edu.cn/showproblem.php?pid=1505Problem DescriptionBob is a strategy game programming specialist. In his new city building game the gaming environment is as fo原创 2017-07-23 20:09:42 · 342 阅读 · 0 评论 -
codeforces.contest/835/problem/C(三维前缀和)
Star skytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Cartesian coordinate system is set in the sky.原创 2017-08-01 09:58:25 · 1587 阅读 · 0 评论 -
hdu 6034 Balala Power!(DP)
Balala Power!Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 998 Accepted Submission(s): 165Problem DescriptionTalented原创 2017-07-25 20:29:24 · 569 阅读 · 0 评论 -
hiho #1532 : 最美和弦(记忆化搜索思路的DP写法)
#1532 : 最美和弦时间限制:10000ms单点时限:1000ms内存限制:256MB描述某个夜晚,Bob将他弹奏的钢琴曲录下来发给Jack,Jack感动之余决定用吉他为他伴奏。我们可以用一个整数表示一个音符的音高,并可认为Bob弹奏的曲子是由3N个整数构成的一个序列。其中每个整数的取值范围是[-200, 200]。Jack共原创 2017-07-16 19:22:33 · 664 阅读 · 0 评论 -
uva Fewest Flops(dp)@
Fewest FlopsTime Limit: 2000msMemory Limit: 131072KBThis problem will be judged on UVA. Original ID: 1155264-bit integer IO format: %lld Java class name: MainPrev Submit Statu原创 2017-04-27 16:39:36 · 334 阅读 · 0 评论 -
hdu 2686 Matrix(最大费用流||多线程DP)@
Yifenfei very like play a number game in the n*n Matrix. A positive integer number is put in each area of the Matrix. Every time yifenfei should to do is that choose a detour which frome the top lef原创 2017-04-26 20:26:58 · 315 阅读 · 0 评论 -
hazu A. Little Red Riding Hood (DP)@
A. Little Red Riding HoodOnce upon a time, there was a little girl. Her name was Little Red Riding Hood. One day,her grandma was ill. Little Red Riding Hood went to visit her. On the way, she met a原创 2017-04-24 10:15:12 · 356 阅读 · 0 评论 -
light oj 1013 - Love Calculator(DP求两个字符串的构造序列方法)
1013 - Love Calculator PDF (English)StatisticsForumTime Limit: 2 second(s)Memory Limit: 32 MBYes, you are developing a 'Love calculator'. The soft原创 2016-09-30 21:53:57 · 213 阅读 · 0 评论 -
51 nod 1201 整数划分(dp)
1259 整数划分 V2基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注将N分为若干个整数的和,有多少种不同的划分方式,例如:n = 4,{4} {1,3} {2,2} {1,1,2} {1,1,1,1},共5种。由于数据较大,输出Mod 10^9 + 7的结果即可。原创 2017-10-10 17:53:31 · 225 阅读 · 0 评论 -
hdu 1024 Max Sum Plus Plus(DP->k段连续区间的最大和)
Max Sum Plus PlusTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionNow I think you have got an AC in Ignatius.L's "Max Sum" proble原创 2017-11-08 11:55:27 · 365 阅读 · 0 评论 -
HRBUST - 2225 粉刷栅栏(分治)
给定一组长度为 n 的栅栏,从左到右高度依次是 h[i]。你需要对这个栅栏粉刷油漆,每次你可以粉刷一行或者一列。问最少粉刷几次,可以给所有栅栏上漆。(不能多刷)Input第一行包含一个整数,表示栅栏的长度。接下来的一行,包含 n 个数(n <= 5000),依次表示 h[i](0 <= h[i] <= 10)。Output输出一行表示对应的答案。Sample In...原创 2019-04-09 20:44:51 · 1311 阅读 · 0 评论 -
neuq 2017: K Multiple Longest Commom Subsequence(LCS变形)
KK has two sequences,A and B, and wants to find the k multiple longest common subsequence.A sequence S is a k multiple common subsequence of A and B if and only if it satisfies the following condition...原创 2019-04-12 16:07:37 · 388 阅读 · 1 评论 -
HRBUST - 2230 括号子序列-A(DP)
一段括号序列被称为平衡的,如果对于任意前缀,左括号的数目都不小于右括号。给定一段括号序列,问有多少括号子序列是平衡的。(内容相同但位置不同的算两种。)Input输入一行括号序列,括号序列的长度 <= 100。Output输出一行表示答案模 10^9 + 7 后的结果。Sample Input(()())()()Sample Output184Hint样例一:()_...原创 2019-04-10 21:53:37 · 538 阅读 · 1 评论 -
pat L3-020 至多删三个字符 (30 分)(DP)
L3-020 至多删三个字符 (30 分)给定一个全部由小写英文字母组成的字符串,允许你至多删掉其中 3 个字符,结果可能有多少种不同的字符串?输入格式:输入在一行中给出全部由小写英文字母组成的、长度在区间 [4, 106 ] 内的字符串。输出格式:在一行中输出至多删掉其中 3 个字符后不同字符串的个数。输入样例:ababcc输出样例:25提示:删掉 0 个字符得到...原创 2019-03-29 17:05:45 · 1170 阅读 · 0 评论 -
51 nod 1376 最长递增子序列的数量(树状数组,同时更改两个变量 长度 方案数)
1376 最长递增子序列的数量1 秒 131,072 KB 160 分 6 级题数组A包含N个整数(可能包含相同的值)。设S为A的子序列且S中的元素是递增的,则S为A的递增子序列。如果S的长度是所有递增子序列中最长的,则称S为A的最长递增子序列(LIS)。A的LIS可能有很多个。例如A为:{1 3 2 0 4},1 3 4,1 2 4均为A的LIS。给出数组A,求A的LIS有多少个。由于数量...原创 2019-03-17 19:58:41 · 305 阅读 · 0 评论 -
leetcode 264. Ugly Number II(DP)
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.Example:Input: n = 10Output: 12Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 ...原创 2019-03-09 20:33:35 · 136 阅读 · 0 评论 -
leetcode 96. Unique Binary Search Trees(DP)
Unique Binary Search TreesMedium148662FavoriteShareGiven n, how many structurally unique BST’s (binary search trees) that store values 1 … n?Example:Input: 3Output: 5Explanation:Given n =...原创 2019-03-02 20:56:44 · 169 阅读 · 0 评论 -
leetcode 123. Best Time to Buy and Sell Stock III(经典DP)
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may not eng...原创 2019-03-05 14:52:19 · 157 阅读 · 0 评论 -
leetcode 72. Edit Distance(经典DP)
Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDelete a characte...原创 2019-02-28 21:15:14 · 203 阅读 · 0 评论 -
51 nod 1636 教育改革(DP)
1636 教育改革题目来源: CodeForces基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注最近A学校正在实施教育改革。一个学年由n天组成。A学校有m门课程,每天学生必须学习一门课,一门课程必须在一天内学习完。在学习完第i门课程后,学生们会收到 xi 个家庭作原创 2018-04-20 23:14:21 · 269 阅读 · 0 评论 -
light oj 1047 - Neighbor House(线性DP)
1047 - Neighbor House PDF (English)StatisticsForumTime Limit: 0.5 second(s)Memory Limit: 32 MBThe people of Mohammadpur have decided to paint each of原创 2017-11-14 17:52:55 · 252 阅读 · 0 评论 -
light oj 1036 - A Refining Company(DP求最大价值和)
1036 - A Refining Company PDF (English)StatisticsForumTime Limit: 3 second(s)Memory Limit: 32 MBIts year 2200, planet Earth is out of resources and pe原创 2016-10-11 10:59:52 · 241 阅读 · 0 评论 -
51 nod 1052 最大M子段和(DP)
1052 最大M子段和基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注N个整数组成的序列a[1],a[2],a[3],…,a[n],将这N个数划分为互不相交的M个子段,并且这M个子段的和是最大的。如果M >= N个数中正数的个数,那么输出所有正数的和。例如:-2 11 -4 13 -5原创 2017-10-25 10:58:41 · 205 阅读 · 0 评论 -
51 nod 1020 逆序排列(递推+DP)
1020 逆序排列基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。如2 4 3 1中,2 1,4 3,4 1,3 1是逆序,逆序数是4。原创 2017-11-01 20:29:22 · 283 阅读 · 0 评论 -
pat 1015. Letter-moving Game (35)(LCS)
1015. Letter-moving Game (35)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CAO, PengHere is a simple intersting letter-movin原创 2017-11-09 00:28:23 · 365 阅读 · 0 评论 -
51 nod 1055 最长等差数列(DP)
1055 最长等差数列基准时间限制:2 秒 空间限制:262144 KB 分值: 80 难度:5级算法题 收藏 关注N个不同的正整数,找出由这些数组成的最长的等差数列。例如:1 3 5 6 8 9 10 12 13 14等差子数列包括(仅包括两项的不列举)1 3 51 5 9 133 6 9 123原创 2017-10-14 10:52:27 · 286 阅读 · 0 评论 -
zzuli 2134: 维克兹的进制转换 (DP)@
2134: 维克兹的进制转换Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 156 Solved: 18SubmitStatusWeb BoardDescription我进入了突如其来的强光。闪烁。闪烁,闪烁,闪烁。我调整好眼睛,评估我前方的景观。有东西在乱窜。我往下看,发现了一只小个的白色生物,用后腿站立着,嗅闻原创 2017-04-24 08:58:28 · 364 阅读 · 0 评论 -
light oj 1421 - Wavio Sequence(LIS)
1421 - Wavio Sequence PDF (English)StatisticsForumTime Limit: 4 second(s)Memory Limit: 32 MBWavio is a sequence of integers. It has some interesting p原创 2017-04-23 09:45:30 · 297 阅读 · 0 评论 -
haut 1265: Hmz 的女装(DP)@
1265: Hmz 的女装时间限制: 2 秒 内存限制: 128 MB提交: 85 解决: 18提交 状态 题目描述Hmz为了女装,想给自己做一个长度为n的花环。现在有k种花可以选取,且花环上相邻花的种类不能相同。Hmz想知道,如果他要求第l朵花和第r朵花颜色相同,做花环的方案数是多少。这个答案可能会很大,你只要输出答案对10^9+7取模的结果即可。输入原创 2017-05-02 10:43:26 · 477 阅读 · 0 评论 -
POJ - 2385 Apple Catching (DP)
Apple CatchingTime Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %lld & %lluSubmit StatusDescriptionIt is a little known fact that cows love apples. Farm原创 2016-10-25 19:43:53 · 204 阅读 · 0 评论