随笔分类 - DP
摘要:数位dp:在数位上做动态规划 Bomb HDU - 3555 求含49的数字个数(49连号)。 #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<queue> #include<c
阅读全文
摘要:树形dp 数的最小点覆盖问题 对于树形dp我的理解是:在一棵树上做动态规划 HDU1054-Strategic Game(题目链接点击题目即可) 题意:给出n个节点 节点编号0~n-1 ,每个节点站一个哨兵,每个哨兵观察到与自己相邻的两条边,问最少需要多少个哨兵才能观察到所有边 题面: Bob en
阅读全文
摘要:##01背包 概念:给定n种物品的价值和重量,每种物品最多只能取一次。求出当背包容量为m时能够装下的最大价值 代码:一维的写法,dp数组代表的是当前状态能够放下的最大价值 for(int i=0;i<n;i++) { for(int j=m;j>=w[i];j--) dp[j]=max(dp[j],
阅读全文
摘要:Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter i
阅读全文
摘要:题意:给出n、c,表示有n层楼,等电梯需要c时间;给出两行数,每行有n-1个数,第一行stairs代表从1楼到每层楼走楼梯需要的时间第二行elevator代表从1楼到每层楼乘电梯需要的时间;需要注意的是,从电梯转电梯不需要等待时间,从楼梯转楼梯也不需要等待时间,但是从楼梯转电梯需要算上等待的时间 t
阅读全文
摘要:题意: 给出t组数据,每组数据再给出num和time,代表下面共有三首歌曲和总共演唱时间,要求求出最长演唱时间和最多歌曲数量,输出时长,若是还有剩余时间,则可以演唱长为678s的歌曲 再给出一组数据 1 3 100 100 100 100 输出:678 为什么我一开始会想到用暴力来写。。。我只想到了
阅读全文
摘要:搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸
阅读全文
摘要:注意一下控制格式即可,最长公共上升子序列模版题 ##AC代码 #include<stdio.h> #include<iostream> #include<algorithm> #include<cmath> #include<iomanip> #include<string.h> using nam
阅读全文
摘要:In Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its na
阅读全文
摘要:A problem that is simple to solve in one dimension is often much more difficult to solve in more than one dimension. Consider satisfying a boolean exp
阅读全文
摘要:##题意 给出一列士兵的身高(会有重复),要求求出剔除最少士兵使得每一个士兵往左或者右看可以看到该队列的尽头士兵,原有的位置不得改变。 ##注意 不能直接排序去剔除除去最高士兵以外有重复的元素,因为题目要求原来的队列顺序不变。 A soldier see an extremity if there
阅读全文
摘要:n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line o
阅读全文