![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
RikkaTheWorld
一个OTAKU
展开
-
POJ1088 滑雪 dp
题目滑雪Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 2原创 2016-04-12 17:15:49 · 394 阅读 · 0 评论 -
UVA1025 A Spy in the Metro
紫书例题 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3466是有向无环图的dp问题 dp[i][j]表示在i时刻j站台要等多少分钟要先预处理在i时刻j站台是否有车,如果有就坐车,没有就等1分钟,然后继续决策。判断是否有车原创 2016-08-05 11:21:19 · 282 阅读 · 0 评论 -
POJ3181 Dollar Dayz
DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer J原创 2016-08-02 10:24:30 · 211 阅读 · 0 评论 -
51nod1007 正整数分组
将一堆正整数分为2组,要求2组的和相差最小。例如:1 2 3 4 5,将1 2 4分为1组,3 5分为1组,两组和相差1,是所有方案中相差最少的。Input第1行:一个数N,N为正整数的数量。第2 - N+1行,N个正整数。(N Output输出这个最小差Input示例512345Output示例1原创 2016-08-17 16:10:57 · 495 阅读 · 0 评论 -
UVA437 The Tower of Babylon
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=378题意是给出n个立方体和他们的三条边的值,这个立方体可以旋转,并且每个立方体有无限多种,要你用这些立方体堆起来尽可能的高,并且下面的立方体的长和宽要严格大于上面立方体的长和宽。把立方体看原创 2016-08-05 20:37:13 · 345 阅读 · 0 评论 -
POJ2479 Maximum sum
DescriptionGiven a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below:Your task is to calculate d(A).InputThe input consists of T(Each test case contains two lin原创 2016-08-08 15:57:21 · 267 阅读 · 0 评论 -
codeforces round 369div2 C Coloring Trees
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integer原创 2016-08-31 22:31:01 · 359 阅读 · 0 评论 -
51nod 1050 循环数组最大子段和
N个整数组成的循环序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑a[n-1],a[n],a[1],a[2]这样的序列)。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。Input第1原创 2016-08-23 01:30:59 · 306 阅读 · 0 评论 -
51nod 1042 数字0-9的数量(数位DP)
给出一段区间a-b,统计这个区间内0-9出现的次数。比如 10-19,1出现11次(10,11,12,13,14,15,16,17,18,19,其中11包括2个1),其余数字各出现1次。Input两个数a,b(1 Output输出共10行,分别是0-9出现的次数Input示例10 19Output示例1111111原创 2016-08-23 18:34:25 · 389 阅读 · 0 评论 -
HDU 5900 QSC and Master(区间DP)
Problem DescriptionEvery school has some legends, Northeastern University is the same.Enter from the north gate of Northeastern University,You are facing the main building of Northeastern Univ原创 2016-09-21 22:26:19 · 307 阅读 · 0 评论 -
51nod 1021 石子归并
题目链接:传送门 从沈阳赛区打铁回来更一发(东北真冷啊)…. 经典的dp问题 dp[i][j]是i到j的最小花费 dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]) 代码如下:#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>u原创 2016-10-28 21:58:17 · 262 阅读 · 0 评论 -
51nod 1101 换零钱(dp)
题目链接:传送门 背包题 状态转移方程式 dp[i]=dp[i-coin[j]]+dp[i]%mod 其中coin[J]是1 2 5 10 20 50…i是总钱 代码如下:#include <bits/stdc++.h>using namespace std;#define N 100100#define mod 1000000007#define inf 2000000000000原创 2016-12-08 14:03:51 · 523 阅读 · 0 评论 -
HDOJ 2067 小兔的棋盘(棋盘dp)
Problem Description小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不原创 2016-07-21 10:34:42 · 509 阅读 · 0 评论 -
01背包几题
写了几道01背包,感觉做的时候想了好久都做不出来,还是有点考察思维的。一: HDOJ 1203 I need a offer 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1203题意是一个人要去投简历给m个学校想拿个offer,每个学校都有自己的申请费ai,这个人 存了n元钱,给出每个学校的申请费和拿到原创 2016-07-31 16:27:24 · 667 阅读 · 0 评论 -
HDPJ 1087 Super Jumping! Jumping! Jumping! (DP)
Super Jumping! Jumping! Jumping!Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little原创 2016-04-13 10:53:13 · 331 阅读 · 0 评论 -
HDOJ1421 搬寝室 DP
搬寝室Description搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度是和左原创 2016-04-14 22:15:27 · 348 阅读 · 0 评论 -
HDOJ 1025 Constructing Roads In JGShining's Kingdom (DP)
转至 点击打开链接Constructing Roads In JGShining's KingdomDescriptionJGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of转载 2016-04-15 22:18:06 · 351 阅读 · 0 评论 -
hdoj 1014 Divding(03背包问题)
Problem DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the转载 2016-07-23 10:46:03 · 443 阅读 · 0 评论 -
Feast Coins(多重背包)
Problem descriptionLast feast the young princess received way too many coins. Since she is very young, she doesn’t know the value of each coin, if you give her a coin with the value 5 or a coi原创 2016-07-26 10:21:21 · 1235 阅读 · 1 评论 -
Codeforces 414b Mashmokh and ACM
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team.原创 2016-07-18 10:30:03 · 434 阅读 · 0 评论 -
POJ1159 Palindrome(滚动数组DP)
PalindromeTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 60017 Accepted: 20898DescriptionA palindrome is a symmetrical string, that is, a string read i原创 2016-07-18 16:49:04 · 311 阅读 · 0 评论 -
HDOJ 1081 To The Max(矩阵DP)
Problem DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or greater located within the whole array. The sum of原创 2016-07-19 08:44:41 · 293 阅读 · 0 评论 -
POJ3624 Charm Bracelet(01背包问题)
题目就不写了,太经典了用二维没有写出来,也没有用滚动数组。#include#include#include#includeusing namespace std;#define N 3500int w[N],d[N];int dp[12880];int main(){ int i,j,n,m; cin>>n>>m; memset(w,0,sizeof(w));原创 2016-07-19 16:40:50 · 247 阅读 · 0 评论 -
Codeforces Round #363 C (Div. 2) Vacations
题目: Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a co原创 2016-07-20 16:49:48 · 253 阅读 · 0 评论 -
51nod 1102 面积最大的矩形
题目链接:这里写链接内容 dp题,面积为一个矩形的左扩展和右扩展边界乘上这个矩形的高度 代码如下:#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;#define N 50010long long int a[N],l[N],r[N];int mai原创 2017-02-06 01:56:05 · 323 阅读 · 0 评论