
ACM_动态规划
文章平均质量分 74
HQD因为有趣所以做题
这个作者很懒,什么都没留下…
展开
-
线性石子归并JOJ2521: Monkey and fruits
2521: Monkey and fruitsStatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K31250StandardAfter culling his most favorite fruits原创 2010-02-19 15:47:00 · 973 阅读 · 0 评论 -
JOJ 2039: Fire Net III
2039: Fire Net IIIStatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout1s10240K22963StandardSuppose that we have a square city wi原创 2010-02-20 09:37:00 · 869 阅读 · 0 评论 -
动态规划之石子合并
石子游戏有两种:一种是博弈方面;另一种是合并规划方面的。前者需要太厉害的判断,而且要用到很多数学方面的结论,所以俺不会。这里主要探讨一下石子归并方面的问题与算法。一. 简单的石子合并问题类似于背包问题:给出n堆石子的数量,请你求出:由这n堆石子可以合并得到的所有重量;或求出合并成两堆之后的最小质量差是多少。其实上一篇谈到的“数字N能否表示成若干个不相同的阶乘的和”就是这个问题的原创 2010-02-19 16:07:00 · 3697 阅读 · 2 评论 -
计算机专业就业方向
希望看到这篇文章的学计算机、软件的同学可以互相转载,让大家都知道我们以后的道路是怎样的。有了方向,干什么都有动力,不是吗?(有点长,希望大家先分享,以后慢慢看,有用没用,我说了不算,你看看就知道了!)计算机专业就业方向一、 关于企业计算方向企业计算(Enterprise Computing)是稍时髦较好听的名词,主要是 指企业信息系统,如ERP软件(企业资源规划)、CRM软件(转载 2010-02-20 12:08:00 · 7131 阅读 · 1 评论 -
2526: medic
2526: medicStatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout1s16384K26487Standard辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟原创 2010-03-08 08:45:00 · 601 阅读 · 0 评论 -
LCS 1829: Candies
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K373113StandardAll children like candie原创 2010-03-08 08:36:00 · 644 阅读 · 0 评论 -
最长单调序列O(nlbn)
http://blog.sina.com.cn/s/blog_4e4148700100cxjm.htmlconst int MAX=2000000;int a[MAX];//求a【ll...rr】的最长严格单调递增序列长度O(nlbn)int bb[MAX];int lcs(int *a,int ll,int rr){ int i,k=1; bb[1]=a[ll];转载 2010-03-08 10:53:00 · 10517 阅读 · 0 评论 -
DP-1424: Coin Change
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K29895StandardSuppose there are 5 types of coins:原创 2010-03-08 08:43:00 · 703 阅读 · 0 评论 -
1129: Divisibility
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K1101268StandardConsider an arbitrary sequence of integers. One can place +原创 2010-03-09 08:56:00 · 676 阅读 · 0 评论 -
从最大子段和问题看算法的优化问题
已有 114 次阅读 2009-06-14 23:29 问题的提出:给定n个整数(可能为负数)组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的子段和的最大值。当所给的整均为负数时定义子段和为0,依此定义,所求的最优值为Max{0,a[i]+a[i+1]+…+a[j]},1 例如,当(a1,a2,a3,a4,转载 2010-03-18 20:10:00 · 607 阅读 · 0 评论 -
2504: Exchange Rates
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s16384K20351StandardNow that the Loonie is hovering about par with the Greenba原创 2010-03-19 21:16:00 · 895 阅读 · 0 评论 -
引用 PKU-DP列表
1014 装箱问题1015 Jury Compromise1029 False coin1036 Gangsters1037 A decorative fence1038 Bugs Integrated, Inc.1042 Gone Fishing1050 To the Max1074 Parallel Expectations1080 Human Gene Functions1088原创 2010-03-19 21:24:00 · 752 阅读 · 0 评论 -
POJ 1014 Dividing
#include #include int a[7],sum,b[100],n;bool dp[60001];int main(){ int i, j, k, t = 1, x; while (scanf ("%d%d%d%d%d%d", &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]) != EOF) { if (a[1]+a[2原创 2010-03-26 21:33:00 · 581 阅读 · 0 评论 -
HDU 2602 Bone Collector
也开始做杭电的题目了#include#includeint main(){ int value[1001],w[1001],f[1001]; int i,j,n,v,count1; freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); while(scanf("%d",&count1)!=EOF) { while(count1原创 2010-03-27 12:56:00 · 596 阅读 · 0 评论 -
HDU Problem A
注意与算法艺术上拿到题目的区别Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 902 Accepted Submission(s): 282Problem DescriptionI’m out of stories. Fo原创 2010-03-28 17:46:00 · 676 阅读 · 0 评论 -
ZOJ Problem Set - 2972
ZOJ Problem Set - 2972Hurdles of 110mTime Limit: 1 Second Memory Limit: 32768 KB <!-- Problem text file for ZheJiang University Online Judge Created by LiuYaoting-->In the year原创 2010-03-28 11:08:00 · 1174 阅读 · 0 评论 -
1028: Dividing Up
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout10s8192K1970401StandardMarsha and Bill own a collection of marbles. They want to spl原创 2010-03-28 11:12:00 · 1018 阅读 · 2 评论 -
PKU 1191 棋盘分割 递归解法
【题意简述】 有一个8*8的棋盘,每次将当前的棋盘分成两半,然后选择一半继续分。 一共分n-1次。 问这n个棋盘的最小均方差是多少? (n 【分析】 先把公式变形: ans^2 = ∑xi^2/n - (x)^2 显然,由于块数是固定的n,平均数(x)等于所有数字的和除n。 那么我们只需原创 2010-03-30 20:07:00 · 881 阅读 · 0 评论 -
POJ 1141 Brackets Sequence
经典的DP,黑书上有,不过要递归求解,以前很少构造最优解,在看了大牛的代码后,也发现黑书的代码也是有待改进的。Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11216 Accepted: 2995 Special JudgeDescriptionLe原创 2010-03-30 19:22:00 · 931 阅读 · 0 评论 -
PKU 2385 各个版本的解法
一个高中生的解法【题意简述】 现在有两棵苹果树,每秒钟其中一棵会落下苹果。 在T秒内(T 问你最多能接到多少个果子。 【分析】 注意这题规模不大,我们可以考虑暴力DP: F[i,j,k] = Max(F[i-1,j-1,1-k],F[i-1,j,k]) (k==loc[i])原创 2010-04-01 19:49:00 · 624 阅读 · 0 评论 -
JOJ 2650: 礼物
ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K10419Standard10*10的格子(1,1)-(10,10)。一个人开始(0秒)站在(1,1)点。每秒他最多可以移动v个格子(但是只能是上下左右,不可以斜着移动)。每一秒钟,天空中会有礼物落下来。当这个人这原创 2010-04-20 21:57:00 · 630 阅读 · 1 评论 -
POJ 2250 Compromise(需要标记的最长公共子串)
CompromiseTime Limit: 1000ms Memory limit: 65536kB 题目描述 In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except原创 2010-07-10 11:19:00 · 694 阅读 · 0 评论 -
1159 Palindrome
PalindromeTime Limit: 3000ms Memory limit: 65536kB 题目描述 A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal numb原创 2010-07-10 14:34:00 · 909 阅读 · 1 评论 -
POJ 1080 Human Gene Functions
<br />1050: Human Gene Functions -------------------------------------------------------------------------------- Result TIME Limit MEMORY Limit Run Times AC Times JUDGE 3s 8192K 378 217 Standard It is well known that a human gene can be considered as a se原创 2010-07-11 09:48:00 · 616 阅读 · 0 评论 -
POJ 2533 Longest Ordered Subsequence
<br />题目没什么意义,第一次用了NLGN的LCS<br /> <br />#include <iostream><br />using namespace std;<br />int a[1001],bb[1001];<br />int lcs(int *a,int ll,int rr)<br />{<br /> int i,k=1;<br /> bb[1]=a[ll];<br /> for(i=ll+1;i<=rr;i++)<br /> {<br /> if(a原创 2010-07-11 11:39:00 · 460 阅读 · 0 评论 -
POJ2192 Zipper
Time Limit: 1000ms Memory limit: 65536kB 题目描述 Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its o原创 2010-07-11 10:24:00 · 818 阅读 · 0 评论 -
1631 Bridging 必须用NLGN的算法
#includeint a[40000],bb[40000];int lcs(int *a,int ll,int rr){ int i,k=1; bb[1]=a[ll]; for(i=ll+1;ibb[k]) bb[++k]=a[i]; else { int ll=1,rr=k,mid; while(ll>1; if(bb[mid]>=a[i])原创 2010-07-11 11:50:00 · 485 阅读 · 0 评论 -
PKU Piggy-Bank
G: Piggy-Bank<br />Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 10000 KB<br />Submit: 50 Accepted: 23 <br />Description<br /><br />Before ACM can do anything, a budget must be prepared and the necessary financial support obtained.原创 2010-07-14 23:18:00 · 710 阅读 · 0 评论 -
PKU Cash Machine
<br />F: Cash Machine<br />Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 10000 KB<br />Submit: 18 Accepted: 9 <br />Description<br />A Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropri原创 2010-07-14 23:16:00 · 618 阅读 · 0 评论 -
HDU 1561 The more, The Better 树状dp
The more, The BetterTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 730 Accepted Submission(s): 365Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地原创 2010-07-20 08:43:00 · 930 阅读 · 0 评论 -
选课 树状DP
#include <iostream>#define _HOME_#define MAXN 300using namespace std;struct node{ int l,r,s,d;} tree[MAXN+1];int f[MAXN+1][MAXN+2],n,m,p1[MAXN+1],p2[MAXN+1];void build(int x){ int i,k=x; tree[x].d=p2[x]; for(i=1;i<=n;++i) if(p1[i]==原创 2010-07-19 22:08:00 · 662 阅读 · 0 评论 -
HDU 1561The more, The Better 树状DP
<br /><br /> <br />The more, The BetterTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 735 Accepted Submission(s): 369<br /><br /><br />Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每原创 2010-07-20 16:24:00 · 535 阅读 · 0 评论 -
HDU 1011 Starship Troopers 树状DP
Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with tunnels. Each room is occupied by some bugs, and their原创 2010-07-20 19:53:00 · 1328 阅读 · 0 评论 -
ZJU 3201 Tree of Tree 树状DP
<br />Tree of TreeTime Limit: 1 Second Memory Limit: 32768 KB <br />You're given a tree with weights of each node, you need to find the maximum subtree of specified size of this tree. <br />Tree Definition <br />A tree is a connected graph which c原创 2010-07-20 20:52:00 · 708 阅读 · 0 评论 -
1191 棋盘分割
#include #include #define INF 10000000 using namespace std;const int m = 8 ;int a[ 10 ][ 10 ];int n;double dp[ 16 ][ 10 ][ 10 ][ 10 ][ 10 ], s[ 10 ][ 10 ][ 10 ][ 10 ];/**/ /* d原创 2010-05-26 23:50:00 · 697 阅读 · 0 评论 -
POJ 1836 Alignment
<br /><br />AlignmentTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 4369 Accepted: 1337<br />DescriptionIn the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of原创 2010-07-29 00:30:00 · 770 阅读 · 0 评论 -
POJ 3176 COW BOWLING
<br />#include<stdio.h><br />int a[360][360],f[360][360];<br />int max(int a,int b)<br />{<br /> if(a>b) return a;<br /> return b;<br />}<br />int main()<br />{<br /> int n;<br /> while(scanf("%d",&n)!=EOF)<br /> {<br /> for(int i=1原创 2010-07-29 10:49:00 · 667 阅读 · 0 评论 -
3267 The Cow Lexicon
<br /><br />The Cow LexiconTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 3615 Accepted: 1592<br />Description<br />Few know that the cows have their own dictionary with W (1 ≤ W ≤ 600) words, each containing no more 25 of the characters 'a'..原创 2010-07-28 22:59:00 · 954 阅读 · 0 评论 -
1260 Pearls
这道题的转移方程是f[i]=min(f[i],f[j]+(....)*p[i]) 转移方程是很容易想到的主要在于证明上首先是如果I<J,当我们一起选了I和J以后,I和J之间的宝石是要和I和J一起连续取的,而不是可以分开,具体证明网上有另外还有一点是不能I取一部分用这个价格买,另一部分用那个价格买,这个证明网上也有PearlsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3288 Accepted: 1547<br />Descripti原创 2010-07-29 10:28:00 · 565 阅读 · 0 评论 -
POJ 1015 Jury Compromise
<br />Jury CompromiseTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14666 Accepted: 3757 Special Judge<br />DescriptionIn Frobnia, a far-away country, the verdicts in court trials are determined by a jury consisting of members of the general原创 2010-08-01 18:12:00 · 1006 阅读 · 0 评论