随笔分类 -  acm dp

上一页 1 2
poj 3624(zeroonepack)
摘要:题目链接:http://poj.org/problem?id=3624#include<iostream>#include<fstream>#include<cstring>usingnamespacestd;intn,m;intw[4000],d[4000];intdp[20000];intmax(inta,intb){if(a>b)returna;elsereturnb;}intmain(){//fstreamcin("x.in");cin>>n>>m;memset(dp,0,sizeof(dp));fo 阅读全文
posted @ 2011-09-24 11:50 追逐. 阅读(208) 评论(0) 推荐(0)
poj 1953 Workd Cup Noise
摘要:DescriptionBackground "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in their home country. But although their excitement is real, the Korean people are still very organized by nature. For example, they have organized h 阅读全文
posted @ 2011-08-14 12:35 追逐. 阅读(354) 评论(0) 推荐(0)
poj 3356 AGTC
摘要:题意: 给定两个字符串,求经过多少次的增删改操作可使两个字符串相同。与poj2192相似,用dp[n]记录使str1前n个字符与str2前m个字符相同的最少操作数。每次的判断都有三种情况,即str1前i个字符str2前j-1个字符,str1前i-1个字符str2前j个字符,str1前i-1个字符str2前j-1个字符。取三种情况经过本次操作后的最小值即可。 代码:#include<iostream>#include<cstring>usingnamespacestd;intmin(inta,intb,intc){intm=1000000;if(a<m)m=a;if 阅读全文
posted @ 2011-08-14 12:34 追逐. 阅读(217) 评论(0) 推荐(0)
poj 1157 LITTLE SHOP OF FLOWERS
摘要:DescriptionYou want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least as many vases ordered in a row. The vases are glued onto the shelf and are numbered consecutively 1 through V, where V is the number of va 阅读全文
posted @ 2011-08-14 12:34 追逐. 阅读(192) 评论(0) 推荐(0)
poj 2192 Zipper
摘要:题意: 给定三个字符串,判断前两个经过字符顺序不变的组合能否变为第三个字符串。 用bool型数组dp[i][j]记录str1的前i个字符和str2的前j个字符能否组合成str3的前i+j个字符。str3的最后一个字符肯定是 str1或str2的最后一个字符,想得到dp[i][j],则必须知道dp[i-1][j](即str1的前i-1个字符和str2的前j个字符能否组合成str3的前i-1+j个字符)和dp[i][j-1](即str1的前i个字符和str2的前j-1个字符能否组合成str3的前i+j-1个字符),由此将问题分解为str1的前n个字符和str2的前m个字符能否组合成str3... 阅读全文
posted @ 2011-08-14 12:33 追逐. 阅读(213) 评论(0) 推荐(0)
poj 1163 数塔
摘要:Description 73 88 1 02 7 4 44 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 the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. In 阅读全文
posted @ 2011-08-14 12:33 追逐. 阅读(225) 评论(0) 推荐(0)
poj 1887 导弹拦截
摘要:A military contractor for the Department of Defense has just completed a series of preliminary tests for a new defensive missile called the CATCHER which is capable of intercepting multiple incoming offensive missiles. The CATCHER is supposed to be a remarkable defensive missile. It can move forwar. 阅读全文
posted @ 2011-08-14 12:27 追逐. 阅读(921) 评论(0) 推荐(0)
poj 1159 回文词
摘要:Description 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 number of characters to be inserted into the string in order to obtain a palindrome. As an e 阅读全文
posted @ 2011-08-11 21:58 追逐. 阅读(244) 评论(0) 推荐(0)

上一页 1 2