
算法
zjc0230
这个作者很懒,什么都没留下…
展开
-
HDU 4504 威威猫系列故事——篮球梦(背包最优方案数)
http://acm.hdu.edu.cn/showproblem.php?pid=4504 知道是DP就很好做了。。。dp[i][j]表示 前i个得分,得分为j的可能性为多少 #include using namespace std ;const int maxn = 66;long long dp[maxn][maxn] ;// 前i个得分,得分为j的可能性为原创 2013-08-01 15:59:43 · 670 阅读 · 0 评论 -
HDU 2577 How to Type (dp)
题意:给出一个包含大小写的字符串,问使用键盘打字至少需要按键多少下,可以使用shift 和caps lock 切换大小写。 Hint 例如The string “Pirates”, can type this way, Shift, p, i, r, a, t, e, s, the answer is 8.The string “HDUacm”, can type this w原创 2013-08-05 11:33:03 · 457 阅读 · 0 评论 -
(树形dp 依赖背包)hdu1561
#include #include using namespace std ;const int maxn = 200+10 ;const int root = 0; //所有森林的根,用于统一模板,本题可以不加struct node{ int father ; vector son ; int bag[maxn]; int num ;}dp[max原创 2013-10-27 18:22:38 · 509 阅读 · 0 评论 -
(树形dp) hdu 1520
#include #include using namespace std ;const int maxn = 6000+10 ;const int root = 0; //所有森林的根,用于统一模板,本题可以不加struct node{ int father ; vector son ; int maxvalue[2]; // 1表示当前节点参加,0表示不原创 2013-10-27 15:31:25 · 521 阅读 · 0 评论 -
离散化
中文名称: 离散化英文名称: discretization定义: 将连续问题的解用一组离散要素来表征而近似求解的方法。把无限空间中有限的个体映射到有限的空间中去,以此提高算法的时空效率。概述: 离散化是程序设计中一个非常常用的技巧,它可以有效的降低时间复杂度。其基本思想就是在众多可能的情况中“只考虑我需要用的值”。离散化可以改进一个低效的算转载 2013-08-07 09:31:19 · 509 阅读 · 0 评论 -
hdu 4517 小小明系列故事——游戏的烦恼
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4517解法:动态规划+滚动数组 #include #include using namespace std ;const int maxn = 2010 ;int n,m;char map[maxn][maxn] ;int row[2][maxn]={0} ,原创 2013-03-23 21:47:05 · 597 阅读 · 0 评论 -
动态规划之背包问题0.1
一、动态规划基本概念1. 概念动态规划是运筹学的一个分支,是求解决策过程(decision process)最优化的数学方法。2. 动态规划的基本思想动态规划算法通常用于求解具有某种最优性质的问题。在这类问题中,可能会有许多可行解。每一个解都对应于一个值,我们希望找到具有最优值的解。动态规划算法与分治法类似,其基本思想也是将待求解问题分解成若干个子问题,先求原创 2017-08-14 09:54:35 · 443 阅读 · 0 评论