动态规划
KIDGINBROOK
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 1080 Human Gene Functions 动态规划
题目大意:两串基因进行匹配(可能不一样长,不够就添加空格),任何两碱基之间以及碱基和空格匹配时所得分数已给出,求可以达到的最大分值。动态规划,两串基因存放在a,b数组中,用ans[ i ][ j ]表示a中前 i 个碱基和b中前 j 个碱基配对时的最大分数,则状态转移方程可以写为: ans[i][j]=max( ans[ i-1 ][ j-1 ] + w[ a[i] ][ b[j] ], an原创 2013-09-26 15:43:11 · 708 阅读 · 0 评论 -
codeforces 1065f Up and Down the Tree 树形dp
F. Up and Down the Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given atreewithnnvertices; its root is vertex...原创 2019-03-23 17:05:15 · 432 阅读 · 0 评论 -
codeforces 1096D Easy Problem dp
D. Easy Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is preparing a contest, and now he has written a statement ...原创 2019-02-06 20:40:25 · 714 阅读 · 0 评论 -
codeforces 1012c Hills dp
C. Hillstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputWelcome to Innopolis city. Throughout the whole year, Innopolis citizens ...原创 2019-02-05 20:08:22 · 541 阅读 · 0 评论 -
codeforces 580d Kefa and Dishes 状压dp
D. Kefa and Dishestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Kefa came to the restaurant and sat at a table, the waite...原创 2018-10-17 21:00:38 · 390 阅读 · 0 评论 -
codeforces 1036C Classy Numbers 数位dp
C. Classy Numberstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call some positive integer classy if its decimal represen...原创 2018-09-19 23:44:48 · 439 阅读 · 0 评论 -
uva 12093 Protecting Zonk 树形dp
题目大意:有n个城市和n-1条路组成了一个树,现在有花费为c1的机器人A和花费为c2的机器人B,两种机器人都是无限量的,如果在城市u放置机器人A,此时与u连接的边都会被覆盖,如果在城市u放置机器人B,那么与u相连的边都会被覆盖,且与u相连的点所相连的边也会被覆盖,现问将所有道路都覆盖所需最小花费dp[u][0] :以点u为根的子树下的边全部被覆盖,且没有向u节点上方覆盖dp[u][原创 2017-11-22 13:46:47 · 608 阅读 · 0 评论 -
codeforces 802K Send the Fool Further! (medium) 树形dp
K. Send the Fool Further! (medium)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThank you for helping He原创 2017-07-27 17:24:32 · 795 阅读 · 0 评论 -
Codeforces Round #382 (Div. 1)
A. Tennis Championshiptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFamous Brazil city Rio de Janeiro ho原创 2016-12-08 13:09:21 · 664 阅读 · 0 评论 -
hdu 5435 A serious math problem 数位dp
问题描述小俊很喜欢数学,现在他要给你出一道严肃的数学题。定义 FxF[x] 为x在十进制表示下各位数字的异或和,例如F1234 1 xor 2 xor 3 xor 4 4F(1234) = 1 xor 2 xor 3 xor 4 = 4。给你两个数 ababa,b(a≤b)。求Fa Fa1 Fa2 Fb2 Fb1 FbF[a] + F[a+1] + F[a+2]+…+ F[b−原创 2015-10-01 11:13:29 · 711 阅读 · 0 评论 -
hdu 5464 Clarke and problem dp
问题描述克拉克是一名人格分裂患者。某一天,克拉克分裂成了一个学生,在做题。 突然一道难题难到了克拉克,这道题是这样的: 给你nn个数,要求选一些数(可以不选),把它们加起来,使得和恰好是pp的倍数(00也是pp的倍数),求方案数。 对于nn很小的时候,克拉克是能轻易找到的。然而对于nn很大的时候,克拉克没有办法了,所以来求助于你。 输入描述第一行一个整数T1T10T(1原创 2015-10-05 11:37:45 · 537 阅读 · 0 评论 -
hdu 5653 Bomber Man wants to bomb an Array dp
问题描述给一个长度为 NN 的一维格子和一些炸弹的位置,请你计算 “最大总破坏指数”。每个炸弹都有向左和向右的破坏力,如果一个炸弹向左和向右的破坏力分别为 LL 和 RR,那么该炸弹将炸毁 L + R + 1L+R+1 个格子(左边LL个,炸弹所在格子,右边RR个)。破坏指数的计算方式为:所有炸弹炸毁的格子数的乘积。假设第 ii 个炸弹炸毁了 X_iXi 个格原创 2016-04-07 11:17:41 · 511 阅读 · 0 评论 -
tc某题。。 dp
大致题意是有一个只包含括号的字符串,长度不超过40,可以删掉一些字符,但不可以全部删完,问有多少种方法使得剩下的字符串是合法的括号匹配。区间dp,dp[l][r] = dp[l + 1][r] + sigma(dp[l + 1][k - 1] * dp[k + 1][r]) 如果(s[l] 和 s[k]匹配)dp[l][r]表示区间l到r的方法数,分为第一个字符留不留,如果不留,就原创 2016-04-07 10:55:17 · 438 阅读 · 0 评论 -
hdu 5433 Xiao Ming climbing bfs
问题描述小明因为受到大魔王的诅咒,被困到了一座荒无人烟的山上并无法脱离.这座山很奇怪:这座山的底面是矩形的,而且矩形的每一小块都有一个特定的坐标xy(x,y)和一个高度HH.为了逃离这座山,小明必须找到大魔王,并消灭它以消除诅咒.小明一开始有一个斗志值kk,如果斗志为0则无法与大魔王战斗,也就意味着失败.小明每一步都能从他现在的位置走到他的NESW(N,E,S,W)四个位置中的一个,会原创 2015-10-01 10:45:44 · 679 阅读 · 0 评论 -
hdu 5148 Cities dp
题意:很久很久以前,有一个叫做杰哥的骑士. 他生活在一个小王国里. 这个王国由n座城市组成,这n座城市通过n-1条道路相连(意味着这个王国是一棵树结构). 由于杰哥打倒了大魔王,并且从魔王手中救出了公主,国王决定奖励他. 国王决定把公主嫁给杰哥,并且送出恰好K座城市,作为公主的嫁妆.那么问题来了. 杰哥在和大魔王对♂战的时候,膝盖中了一剑,因此杰哥希望他的K座城市离得越近越好. 这就是说,杰哥原创 2015-01-14 21:28:14 · 811 阅读 · 0 评论 -
cf 408D - Long Path dp
题意:有一排房间每个房间有两扇门,一扇通往第i+1个房间,另一扇通往第p[i]个房间,然后他每经过一个房间就做一个标记,只有偶数个标记时他才会走第一扇门。问你他要走多少单位时间。原创 2014-06-15 21:11:59 · 723 阅读 · 0 评论 -
cf 429B Working out dp
#include #include int sc[1010][1010];int dp1[1010][1010];int dp2[1010][1010];int dp3[1010][1010];int dp4[1010][1010];int MAX(int a,int b){ if(a>b) return a; else return b;}int main()原创 2014-05-12 23:26:15 · 867 阅读 · 0 评论 -
codeforces 1153D Serval and Rooted Tree 树形dp
D. Serval and Rooted Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow Serval is a junior high school student in Japari Mi...原创 2019-04-28 14:21:07 · 312 阅读 · 0 评论
分享