动态规划
Albert_Bolt
这个作者很懒,什么都没留下…
展开
-
杭电1423(最长递增公共子序列 LICS)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description This is a problem from ZOJ 2432.To make it easyer,you ju...原创 2018-07-18 11:42:21 · 267 阅读 · 0 评论 -
杭电2829(斜率dp)
Lawrence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description T. E. Lawrence was a controversial figure during World War I. He was a British officer...原创 2018-08-14 16:11:13 · 203 阅读 · 0 评论 -
杭电1074(交作业+状态压缩)
Doing Homework(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lo...原创 2018-08-02 14:59:22 · 297 阅读 · 0 评论 -
杭电1087(和最大的递增子序列)
Super Jumping! Jumping! Jumping!(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Nowadays, a kind of chess game called “Super Jumping! Ju...原创 2018-08-03 09:47:18 · 493 阅读 · 0 评论 -
杭电1078(仓鼠吃奶酪,DFS+动态规划)
FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description FatMouse has stored some cheese in a city. The city can be considered as a ...原创 2018-08-02 21:05:46 · 1055 阅读 · 0 评论 -
杭电1114(完全背包)
Piggy-Bank(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Before ACM can do anything, a budget must be prepared and the necessary fina...原创 2018-08-03 10:50:37 · 374 阅读 · 0 评论 -
杭电3045(斜率dp)
Picnic Cows Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description It’s summer vocation now. After tedious milking, cows are tired and wish to take a ...原创 2018-08-15 16:05:37 · 174 阅读 · 0 评论 -
杭电1158(公司雇人)
Employment Planning(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description A project manager wants to determine the number of the workers needed...原创 2018-08-08 11:40:27 · 196 阅读 · 0 评论 -
杭电2993 && POJ2018(斜率dp)
MAX Average Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Consider a simple sequence which only contains positive integers as a1, a2 ...原创 2018-08-15 22:39:08 · 217 阅读 · 0 评论 -
背包问题
一、01背包 题目 有n件物品,容量为V的背包 放入第 i 件物品耗费的费用是ci,得到的价值是wi 求解将哪些物品装入背包可使价值总和最大 特点 每种物品仅有1件,可以选择放或不放。 状态转移方程 dp[j]表示背包内放入物品费用为 j 时的最大价值 dp[j] = max { dp[j], dp[ j - ci ] + wi } 初始化 要求恰好装满背包:dp[0]=0...原创 2018-09-05 11:39:20 · 173 阅读 · 0 评论 -
杭电3507(斜率dp)
Print Article Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Problem Description Zero has an old printer that doesn’t work well sometimes. As it is antique, he s...原创 2018-08-14 14:46:03 · 268 阅读 · 0 评论 -
状态压缩DP
讲解        对问题的状态进行压缩,将状态转化为二进制的形式,通过位运算进行操作,要注意位运算符的优先级。 使用 在问题规模较小时使用。 位运算 对x取反:~x x+1(x为偶数):x|1 2x:1<...原创 2018-08-02 10:11:56 · 139 阅读 · 0 评论 -
斜率dp
斜率dp 模型 给定一个序列,分成若干段,分段有一定的限制条件,并需要一定的费用,问怎样分段才能在满足限制条件的情况下,使费用最小。 条件 状态转移方程类似于:dp[i] = dp[j] + (x[i] - x[j]) * (x[i] - x[j])。无法转化成dp[i] = f[j] + x[i]的形式。 抽象 将dp[i] = dp[j] + (x[i] - x[j])...原创 2018-08-14 11:46:54 · 265 阅读 · 0 评论 -
杭电1142(dijkstra最短路+DFS记忆化搜索)
A Walk Through the Forest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Jimmy experiences a lot of stress at work these days, especially si...原创 2018-07-18 21:58:52 · 320 阅读 · 0 评论 -
杭电1003(最大子串和)
Max Sum(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Given a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a ...原创 2018-08-01 09:37:46 · 780 阅读 · 0 评论 -
杭电1025(最长上升子序列+二分查找优化)
Constructing Roads In JGShining’s Kingdom(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description JGShining’s kingdom consists of 2n(n is no more...原创 2018-08-01 11:02:37 · 384 阅读 · 0 评论 -
杭电1058(输出第n个humble数)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...原创 2018-08-01 14:57:25 · 246 阅读 · 0 评论 -
杭电1059(多重背包)
Dividing(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Marsha and Bill own a collection of marbles. They want to split the collection a...原创 2018-08-06 11:38:59 · 240 阅读 · 0 评论 -
杭电2191(多重背包)
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description 急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大...原创 2018-08-10 11:32:12 · 222 阅读 · 0 评论 -
杭电1069(按长宽从大到小往上堆高塔)
Monkey and Banana(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description A group of researchers are designing an experiment to test the IQ of a ...原创 2018-08-01 17:13:19 · 342 阅读 · 0 评论 -
杭电2602(01背包)
Bone Collector(难度:1) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone ...原创 2018-08-06 15:52:48 · 491 阅读 · 0 评论 -
动态规划的几个模板
错排公式 dp[1]=0; dp[2]=1; for(int i=3;i<=20;i++) { dp[i]=(i-1)*dp[i-1]+(i-1)*dp[i-2]; } cin>>n; cout<<dp[n]<<endl; 最长递增子序列 LIS for(int i=1;i<=n;i++) { int tmax=1; ...原创 2018-09-05 15:57:20 · 548 阅读 · 0 评论