
动态规划
L-75
这个作者很懒,什么都没留下…
展开
-
最长公共子序列
#include #include int a[1005][1005];int s[1005][1005];void LCSLength(char *str1,char *str2,int len1,int len2){ int i,j; for(i=1;i<=len1;i++) { for(j=1;j<=len2;j++) { if(str1[i-1]==str2[原创 2015-08-13 08:40:13 · 365 阅读 · 0 评论 -
HDU 2082 找单词(母函数)
找单词Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6496 Accepted Submission(s): 4542Problem Description假设有x1个字母A, x2个字母B,....原创 2016-11-11 15:22:47 · 690 阅读 · 0 评论 -
SDUT 2879 Colorful Cupcakes (2014年山东省第五届ACM大学生程序设计竞赛)
Colorful CupcakesTime Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^题目描述Beaver Bindu has N cupcakes. Each cupcake has one of three possible colors. In this problem we will re原创 2016-06-02 10:31:55 · 380 阅读 · 0 评论 -
HDU 1260 Tickets (简单DP)
TicketsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2364 Accepted Submission(s): 1152Problem DescriptionJesus, what a grea原创 2016-03-06 09:00:11 · 380 阅读 · 0 评论 -
HDU 2571 命运(简单经典DP)
命运Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14387 Accepted Submission(s): 5074Problem Description穿过幽谷意味着离大魔王lemon已经无限接近了!原创 2016-03-04 09:04:17 · 414 阅读 · 0 评论 -
HDU 1331 Function Run Fun(记忆化搜索)
Function Run FunTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3358 Accepted Submission(s): 1652Problem DescriptionWe all love原创 2016-01-20 16:37:40 · 395 阅读 · 0 评论 -
HDU 1500 Chopsticks(动态规划)
ChopsticksTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1885 Accepted Submission(s): 882Problem DescriptionIn China, people u原创 2016-01-20 15:17:41 · 710 阅读 · 0 评论 -
HDU 1243 反恐训练营
反恐训练营Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3564 Accepted Submission(s): 840Problem Description当今国际反恐形势很严峻,特别是美国“9.11事原创 2016-01-16 10:35:06 · 809 阅读 · 0 评论 -
HDU 2602 Bone Collector
Bone CollectorTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 41458 Accepted Submission(s): 17255Problem DescriptionMany years原创 2015-10-27 16:22:42 · 325 阅读 · 0 评论 -
HDU 2059 龟兔赛跑
龟兔赛跑Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13906 Accepted Submission(s): 5175Problem Description据说在很久很久以前,可怜的兔子经历了人生中最原创 2015-10-12 22:47:09 · 464 阅读 · 0 评论 -
HDU 1284钱币兑换问题
钱币兑换问题Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7866 Accepted Submission(s): 4679Problem Description在一个国家仅有1分,2分,3分硬币,将钱N兑换原创 2015-10-09 15:49:03 · 534 阅读 · 0 评论 -
HDU 1466 计算直线的交点数
计算n条直线的交点数:计算1条直线平行(即都不平行),交点为dp[n-1][j+1*(n-1)];计算2条直线平行,交点为dp[n-2][j+2*(n-2)]; ......计算i条直线平行,交点为dp[n-2][j+2*(n-2)]; ......另外还有dp[i]原创 2015-09-09 19:14:10 · 384 阅读 · 0 评论 -
背包问题总结(01背包、完全背包、多重背包)
1、 01背包问题有n个物品,每个物品只有一件。动归方程:(1) 二维数组解法 dp[i][j]=max{dp[i-1][j-w[i]]+v[i] , dp[i-1][j]};(2) 一维数组解法 dp[j]=max{dp[j-w[i]]+v[i] , dp[j]}附代码:HDU 2602 Bone Collector二维数组:#in原创 2015-09-01 21:50:01 · 1201 阅读 · 0 评论 -
HDU 1501 Zipper
Zipper Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 23 Accepted Submission(s) : 6Font: Times New Roman | Verdana | GeorgiaFont Size原创 2015-08-15 21:29:50 · 578 阅读 · 0 评论 -
HDU 1159
最简单的最长公共子序列问题上AC的代码//最长公共子序列#include #include int a[1005][1005];void LCSLength(char *str1,char *str2,int len1,int len2){ int i,j; for(i=1;i<=len1;i++) { for(j=1;j<=len2;j++) { if(str1原创 2015-08-13 08:46:40 · 727 阅读 · 0 评论 -
HDU 1003
最大子段和,经典的DP问题,对于刚接触DP的我,无限次的WA。一个简单的子段和问题,要注意,sum初值要设为无穷小,设为0是过不了的,还要注意,对于左右界来说,要有初值。上代码#include int main(){ int T,n; int i,j,sum,b,a,l,r,temp; scanf("%d",&T); for(j=1;j<=T;j++) { b=0;原创 2015-08-13 09:40:18 · 414 阅读 · 0 评论 -
矩阵连乘问题(动态规划)
因为矩阵乘法满足结合律不满足交换律,所以矩阵乘法进行的顺序呢不同的相乘次数就有所不同。例如{A1,A2,A2}:A1 10*100A2 100*5A3 5*50A1A2A3,有两种加括号形式,即,(A1A2)A3和A1(A2A3);第一种乘积数乘次数为:10*100*5+5*100*50=7500第二种乘积数乘次数为:100*5*50+10*100*50=75000原创 2015-08-13 00:15:26 · 1238 阅读 · 0 评论 -
HDU 1087 Super Jumping! Jumping! Jumping!(DP)
Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 36136 Accepted Submission(s): 16478Problem Descri原创 2017-03-01 17:09:21 · 300 阅读 · 0 评论