
简单dp
活的钻石
每时每刻都是活生生的,都走向活的方向,都有安全的活。
每一个刹那都淳珍宝爱,都充满热诚于美,都有创造的力。
那么,生命就会有钻石的美好,钻石的光芒了。
展开
-
Monkey and Banana HDU - 1069
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...原创 2019-03-30 14:46:00 · 221 阅读 · 0 评论 -
dp入门之LCS (最长公共子序列) LIS(最长上升子序列)数塔问题
LCS:最长公共子序列就是说给你两个序列x={x1,x2,x3……,xm}和y={y1,y2,y3,……,ym}找出x和y的一个最长的公共子序列。思路:如果是暴力枚举则为枚举x序列的所有子序列,检查每个子序列是否也是y的子序列,记录找到最长的公共子序列,共有2^m种情况,暴力枚举的时间复杂度为指数阶.时间复杂度特别高,在m比较小时可以直接枚举,但如果很大时,会超时。所以想到了动态规...原创 2019-03-30 20:56:02 · 249 阅读 · 0 评论 -
HDU - 1087 Super Jumping! Jumping! Jumping!
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game can...原创 2019-03-31 11:46:44 · 121 阅读 · 0 评论 -
区间DP值入门题目——石子归并
这两天特别丧,不想学习,心态有点崩。不知道为什么,可能是假期综合症吧,又感觉自己处在了一种极度的迷茫之中,都怪袁老,让我自己一天吃饱了没事干,胡思乱想,呜呜呜.jpg。区间DP区间DP就是在区间上的动态规划,求解一段区间上的最优解,通过合并小区间的最优解来得到整个大区间上的最优解的算法。时间复杂度一般为O(n^2)或者O(n^3),一般做法就是:确定状态,例如初始化等操作。...原创 2019-04-06 18:03:35 · 411 阅读 · 0 评论 -
FatMouse and Cheese HDU - 1078
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid lo...原创 2019-04-06 23:43:36 · 133 阅读 · 0 评论 -
The Triangle POJ - 1163
73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top an...原创 2019-04-01 21:31:46 · 162 阅读 · 0 评论 -
区间DP训练集锦
第一题 石子合并问题--直线版HRBUST - 1818可以自行在vj上查题,最基础的石子问题,昨天没过,今天过了,vj有毒。#include<iostream>#include<cstdio>#include<algorithm>using namespace std;const int maxn=101;const int I...原创 2019-04-08 08:28:56 · 256 阅读 · 0 评论 -
免费馅饼 HDU - 1176
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...原创 2019-04-03 00:26:42 · 211 阅读 · 0 评论 -
基础线性DP总结
动态规划是一种求解最优解的思想。通常情况下要分清楚动规和贪心,什么时候用贪心,什么时候用动规。1.数字三角形问题动规方程:dp[i][j]=a[i][j]+max{dp[i+1][j],dp[i+1][j+1]}。每次从i,j走有两种选择下dp[i+1][j]和 右下dp[i+1][j+1].全局最优解包含局部最优解。动态规划的核心是状态转移方程。The Triangle P...原创 2019-04-17 19:55:28 · 424 阅读 · 0 评论