随笔分类 -  DP

摘要:http://codeforces.com/contest/574/problem/D/*容易得到状态方程dp[i] = min(a[i], dp[i-1]+1,dp[i-2]+2 ....dp[i+1]+1,,,)那么可以得到两个递推式dp[i] = min(a[i], 之间的min+1)dp[i... 阅读全文
posted @ 2015-08-31 15:38 Painting、时光 阅读(153) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5389/*数相加超过两位数个十位相加等价于所有数相加Mod9大意: 有两扇门,n个人,要使得这些人全部进去这两扇门,进去的条件是两个sum_group模9为门上的数,问有多少种方案定义 dp[i][j] 已经选了i... 阅读全文
posted @ 2015-08-14 15:22 Painting、时光 阅读(431) 评论(0) 推荐(0)
摘要:格雷值与二进制转化公式,G[i] = B[i]^B[i-1],二进制前面补0dp[i][j]定义为当前是第i个格雷值,值是j的和* Author :powatr* Created Time :2015-8-11 13:19:46* File Name :1007.cpp **... 阅读全文
posted @ 2015-08-12 11:17 Painting、时光 阅读(159) 评论(0) 推荐(0)
摘要:Soda has a bipartite graph withnvertices andmundirected edges. Now he wants to make the graph become a complete bipartite graph with most edges by add... 阅读全文
posted @ 2015-08-01 15:39 Painting、时光 阅读(175) 评论(0) 推荐(0)
摘要:Bobo has a tree,whose vertices are conveniently labeled by 1,2,...,n.Each node has a weightwi. All the weights are distrinct.A set with m nodesv1,v2,.... 阅读全文
posted @ 2015-07-29 13:57 Painting、时光 阅读(136) 评论(0) 推荐(0)
摘要:roblem DescriptionTom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a abil... 阅读全文
posted @ 2015-07-22 15:50 Painting、时光 阅读(150) 评论(0) 推荐(0)
摘要:Vasya has a very beautiful country garden that can be represented as ann × mrectangular field divided inton·msquares. One beautiful day Vasya remember... 阅读全文
posted @ 2015-07-20 14:33 Painting、时光 阅读(207) 评论(0) 推荐(0)
摘要:Ytaaa作为一名特工执行了无数困难的任务,这一次ytaaa收到命令,需要炸毁敌人的一个工厂,为此ytaaa需要制造一批炸弹以供使用。 Ytaaa使用的这种新型炸弹由若干个炸药组成,每个炸药都有它的威力值,而炸弹的威力值为组成这个炸弹的所有炸药的最大威力差的平方,即(max-min)^2,假设一个炸... 阅读全文
posted @ 2015-07-15 21:34 Painting、时光 阅读(161) 评论(0) 推荐(0)
摘要:DescriptionAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and de... 阅读全文
posted @ 2015-07-15 00:18 Painting、时光 阅读(209) 评论(0) 推荐(0)
摘要:Problem DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share... 阅读全文
posted @ 2015-05-29 20:54 Painting、时光 阅读(698) 评论(0) 推荐(0)
摘要:Two soldiers are playing a game. At the beginning first of them chooses a positive integernand gives it to the second soldier. Then the second one tri... 阅读全文
posted @ 2015-05-26 20:15 Painting、时光 阅读(161) 评论(0) 推荐(0)
摘要:Problem Description近期B厂组织了一次大搬家,所有人都要按照指示换到指定的座位上。指示的内容是坐在位置i上的人要搬到位置j上。现在B厂有N个人,一对一到N个位置上。搬家之后也是一一对应的,改变的只有位次。在第一次搬家后,度度熊由于疏忽,又要求大家按照原指示进行了一次搬家。于是,机智... 阅读全文
posted @ 2015-05-25 10:51 Painting、时光 阅读(188) 评论(0) 推荐(0)
摘要:Problem DescriptionJGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these ci... 阅读全文
posted @ 2015-05-22 20:39 Painting、时光 阅读(112) 评论(0) 推荐(0)
摘要:Problem DescriptionNow I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more diffic... 阅读全文
posted @ 2015-05-22 19:50 Painting、时光 阅读(128) 评论(0) 推荐(0)
摘要:Problem 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)... 阅读全文
posted @ 2015-05-21 16:10 Painting、时光 阅读(144) 评论(0) 推荐(0)
摘要:Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining ... 阅读全文
posted @ 2015-05-20 15:33 Painting、时光 阅读(286) 评论(0) 推荐(0)
摘要:Problem DescriptionFish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that t... 阅读全文
posted @ 2015-05-18 16:59 Painting、时光 阅读(193) 评论(0) 推荐(0)
摘要:输入一个n,以及n个数据,输出最长的不下降的子序列大意:有两种思路:1.O(n^2)想法用一个num来记录以该数字为末数字的长度用一个if限制两个条件,后面小于前面并且后面的长度大于前面的长度+1那么说明需要更新了,最后只要遍历所有的数字在num中看以那个数字为开始点的长度最长。这个比较好理解#in... 阅读全文
posted @ 2015-05-13 19:39 Painting、时光 阅读(252) 评论(0) 推荐(0)
摘要:DescriptionThe railway line “Yekaterinburg-Sverdlovsk” with several stations has been built. This railway line can be represented as a line segment, r... 阅读全文
posted @ 2015-05-12 20:20 Painting、时光 阅读(202) 评论(0) 推荐(0)
摘要:DescriptionMr. F. wants to get a document be signed by a minister. A minister signs a document only if it is approved by his ministry. The ministry is... 阅读全文
posted @ 2015-05-12 16:32 Painting、时光 阅读(130) 评论(0) 推荐(0)