自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 收藏
  • 关注

原创 hdu 1503 Advanced Fruits

http://acm.hdu.edu.cn/showproblem.php?pid=1503最长公共子序列 用个p[i][j]记录dp[i][j]是从哪个位置传递过来的然后dfs输出,基本都是看的别人题解,然后自己写的,就不多说了代码:#include #include #include #include #include #include #include #inc

2012-11-17 12:07:53 454

原创 hdu 1502 Regular Words

http://acm.hdu.edu.cn/showproblem.php?pid=1502catalan数,可以直接套公式这里居然有DP方程,太神了dp[i][j][k]=dp[i-1][j][k]+dp[i][j-1][k]+dp[i][j][k-1];i-1>=j>=k,i>=j-1>=k,i>=j>=k-1 这里要分别讨论初始化也是个问题方程解释一下,dp[i]

2012-11-16 21:43:07 552

原创 hdu 3008 Warcraft

http://acm.hdu.edu.cn/showproblem.php?pid=3008dp[i][j]表示第i秒 魔法值为j的时候对BOSS的伤害这里用递推,因为你的魔法是在所有攻击完后才会增加#include #include #include #include #include #include #include #include #include using

2012-11-16 10:31:11 992

原创 hdu 1227 fast food

http://acm.hdu.edu.cn/showproblem.php?pid=1227 dp[i][j]=min(dp[i-1][k]+cost[k+1][j],dp[i][j]);dp[i][j]表示供应点个数为i的时候对于前j个位置,最小的sum这里i到j这个区间中 取一个点使之所有点到这个点取得最小的距离和 那么这个点必定在(i+j)/2的位置cost[i][j]表示i

2012-11-14 16:07:59 417

原创 hdu zipper 1501

http://acm.hdu.edu.cn/showproblem.php?pid=1501记忆化搜索由于第三个串是由 前两个串按顺序组成的 那么从前两个串的 第一位 和 第三个串的第一位 开始比 相等就比下一个能比到尾就行了从这些路径中找出可行的 记忆化搜索代码:#include #include #include #include #include #incl

2012-11-14 00:05:37 529

原创 poj 2485 Highway

http://poj.org/problem?id=2485最小生成树 模板题kruscal算法代码:#include #include #include #include #include #include #include #include #include using namespace std;int p[505];struct node{

2012-11-12 22:27:17 420

原创 hdu 1422 重温世界杯

http://acm.hdu.edu.cn/showproblem.php?pid=1422暴力水过,正解应该是DP最长非负子序列a[i]为第i个 生活费-花费if(sum[i-1]+a[i]>=0){    dp[i]=dp[i-1]+1;    sum[i]=sum[i-1]+a[i];    maxn=max(maxn,dp[i]);}else

2012-11-12 21:40:26 448

原创 hdu 1074 Doing Homework

http://acm.hdu.edu.cn/showproblem.php?pid=1074状态压缩DP 的模板题学习了一下状态压缩DP这里处理字典序的方法 有排序,貌似排序的还简单一些我用的指针signp指向上一个状态,p指向状态对应取的字符串代码:#include #include #include #include #include #inclu

2012-11-12 18:51:14 505

原创 hdu 1059 Dividing

http://acm.hdu.edu.cn/showproblem.php?pid=1059多重背包 用二进制优化 本来还想直接从小到大放的那个方法 貌似只适用于完全背包代码:#include #include #include #include #include #include #include #include #include using namespace

2012-11-11 09:38:23 426

原创 hdu 1158 Employment Planning

http://acm.hdu.edu.cn/showproblem.php?pid=1158dp[i][j] 表示第i月留j个人最少的话费代码:#include #include #include #include #include #include #include #include #include using namespace std;#define Deb

2012-11-11 02:11:50 438

原创 hdu 2059 龟兔赛跑

http://acm.hdu.edu.cn/showproblem.php?pid=2059一开始想多了代码基本上抄的 关键是没搞懂为什么不考虑加油为什么也能 AC仔细一看 原来j=0的时候就已经把每个状态的不加油的情况考虑进去了代码:#include #include #include #include #include #include #include #i

2012-11-10 23:05:39 450

原创 hdu 1081 To The Max

http://acm.hdu.edu.cn/showproblem.php?pid=1081转换成 最大连续子序列就行了代码:#include #include #include #include #include #include #include #include #include #include using namespace std;int matrix

2012-11-09 21:57:19 351

原创 hdu 1078 FatMouse and Cheese

http://acm.hdu.edu.cn/showproblem.php?pid=1078哈哈 记忆化搜索 第一次自己写的过了努力终于有回报了啊^-^代码:#include #include #include #include #include #include #include #include #include using namespace std;in

2012-11-09 19:35:36 405

原创 hdu 1025 Cstructing Roads

http://acm.hdu.edu.cn/showproblem.php?pid=1025对p进行排序,然后就是对rich的最长上升子序列的求法,只是o(n^2)的算法不行,要用d[i]表示序列长度为i时,最小的数为d[i],查找的时候用二分查找,查完的在把最小的放进去代码:#include #include #include #include #include #in

2012-11-09 14:44:10 453

原创 hdu piggy-bank 1114

http://acm.hdu.edu.cn/showproblem.php?pid=1114完全背包求最小值这题貌似正着求一次 用个二维就行了我的方法有点2B 反着求 用了二进制优化二维的懒的写了代码:#include #include #include #include #include #include #include #include #in

2012-11-07 12:35:03 419

原创 hdu 2191 HDU 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活

http://acm.hdu.edu.cn/showproblem.php?pid=2191简单多重背包题目代码:#include #include #include #include #include #include #include #include #include using namespace std;int f[105];struct node{

2012-11-07 00:21:36 578

原创 hdu 1978 How many ways

http://acm.hdu.edu.cn/showproblem.php?pid=1978DP好吧,我不能很好的理解题目的意思做法就是从每个点出发能到的曼哈顿距离的点就全部加上此点的路径数先是DP写法,准备在写个记忆化搜索练习下代码:#include #include #include #include #include #include #inclu

2012-11-06 00:17:58 360

原创 codeforces 148 div2 C

http://codeforces.com/contest/239/problem/C到第i位就有i-1种子序列组成的不同值 例如m=2时 1 2,有1和1^2,那么如果n=3的话就只能放一个从i=1递推过去代码:#include #include #include #include #include #include #include #include #in

2012-11-05 15:46:51 448

原创 codeforces 148 div2 B

http://codeforces.com/contest/239/problem/B蛋疼的模拟题 并不难 直接模拟就行 郁闷 codeforces上的题目总是看的蛋疼 老是看不懂要么搞错题意 比赛时候看题就浪费快半个小时 而且好像还忽略了某个条件代码贴着做教训代码:#include #include #include #include #include #inclu

2012-11-05 11:57:02 407

原创 hdu 1789 Doing Homework again

http://acm.hdu.edu.cn/showproblem.php?pid=1789这题贪心 每次找分数最多的看能不能全部完成 不能的话就舍去 去找下一个这个我还真没想到 看题解才知道 这题隐蔽性真大 还有就是判断能不能全部完成那里 我卡主了 蛋疼代码:#include #include #include #include #include #include #

2012-11-04 22:52:19 323

原创 hdu 1421 搬寝室

http://acm.hdu.edu.cn/showproblem.php?pid=1421先排序然后dpdp方程为:dp[i][j]=min(dp[i-2][j-1]+(num[i]-num[i-1])^2,dp[i-1][j]);表示到i之前(包括i)搬j对需要的最少疲劳值注意处理好一下边界就好代码:#include #include #include #in

2012-11-03 17:52:29 364

原创 hdu 1159 Common Subsequence

http://acm.hdu.edu.cn/showproblem.php?pid=1159最长公共子序列不解释代码:#include #include #include #include #include #include #include #include #include using namespace std;char word1[1005];char w

2012-11-03 11:36:57 358

原创 hdu 2830 Matrix Swapping II

http://acm.hdu.edu.cn/showproblem.php?pid=2830先求出每一行的高度,然后对于每一行有多少个 存在高度 用个hash存起来后面枚举的时候 先排序从大到小,然后 二维只枚举到hash存起来的数就行了,排序是为了方便求对于每一行求矩阵且节省时间,因为0的就跳过了矩阵求法 ans=max(height[i][j]*j,ans); 因为前面大的

2012-11-02 22:57:18 321

原创 codeforces 241 A

http://codeforces.com/contest/241/problem/A这题感觉很经典 就写了一下这题贪心,每次如果不能到达某个地方,就一直最后在前面的城市中选油田供给最多的去加油,我也这么想过,但不知道怎么实现,应该收很麻烦看了大神的代码后豁然开朗,其实就用一个变量记录到这个方面前面最多油田的供给量,然后每次不能到时候去加这个就行了代码:#include #i

2012-11-02 12:37:54 399

原创 hdu 2870 Largest Submatrix

http://acm.hdu.edu.cn/showproblem.php?pid=2870和1506 和1505类似的解法一个关键的优化就是if(!num[j])  continue;说实话不是想不到,关键是懒的加,因为看起来不可能优化多少现在知道了,以后能优化的尽量优化,这个不加就是超时与不超时的关系代码:#include #include #inclu

2012-11-02 00:28:43 371

原创 hdu 2845 Beans

http://acm.hdu.edu.cn/showproblem.php?pid=2845dp[i]表示在i之前(包括i) 最大得的分数dp[i]=(dp[i],dp[i-2]+matrix[i]);每一行这么求一次,然后最后一列竖着求一次因为我不知道他的分数会不会为负数,所以我用的max有三个变量代码:#include #include #include #i

2012-11-01 12:39:59 321

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除