
动态规划
SpongeBob_Y
这个作者很懒,什么都没留下…
展开
-
HDU 1059 Dividing(多重背包+二进制优化)
题目链接Marsha 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 marbles had the ...原创 2018-07-07 14:13:29 · 1863 阅读 · 1 评论 -
CF 148D Bag of mice (概率DP)
The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they sh...原创 2018-12-11 15:47:06 · 308 阅读 · 0 评论 -
POJ 2342 Anniversary party(树型DP入门题)
题目链接DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor ...原创 2019-01-06 11:01:39 · 203 阅读 · 0 评论 -
HDU 5956 The Elder(树型DP+斜率优化)
题目链接Problem DescriptionOnce upon a time, in the mystical continent, there is a frog kingdom, ruled by the oldest frog, the Elder. The kingdom consists of N cities, numbered from east to west. The ...原创 2019-01-11 14:40:12 · 253 阅读 · 0 评论 -
lightoj 1030 - Discovering Gold(概率DP)
You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold.Initially you are in position 1. Now each turn you throw a perfect 6...原创 2019-01-07 09:11:51 · 169 阅读 · 0 评论 -
LightOJ 1422 Halloween Costumes(区间DP)
Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it's Halloween, these parties are all costume parties, Gap...原创 2019-01-07 20:22:20 · 157 阅读 · 0 评论 -
BZOJ 3679 数字之积(数位DP)
一个数x各个数位上的数之积记为f(x) <不含前导零>求[L,R)中满足0<f(x)<=n的数的个数Input第一行一个数n第二行两个数L、ROutput一个数,即满足条件的数的个数Sample Input5 19 22Sample Output1Hint 100% 0<L<R<10^18 , n&l...原创 2019-01-08 11:27:07 · 320 阅读 · 0 评论 -
Codeforces Round #533 (Div. 2)(C,D)题解
比赛链接Ayoub had an array aa of integers of size nn and this array had two interesting properties:All the integers in the array were between ll and rr (inclusive). The sum of all the elements was di...原创 2019-01-21 19:55:23 · 277 阅读 · 0 评论 -
HDU 4507 吉哥系列故事——恨7不成妻(数位DP+详解)
题目连接 单身! 依然单身! 吉哥依然单身! DS级码农吉哥依然单身! 所以,他生平最恨情人节,不管是214还是77,他都讨厌! 吉哥观察了214和77这两个数,发现: 2+1+4=7 7+7=7*2 77=7*11 最终,他发现原来这一切归根到底都是因为和7有关!所以,他现在甚至讨厌一切和7有关的数! 什么样的数和7有关呢?...原创 2019-02-22 23:44:16 · 403 阅读 · 0 评论 -
数位DP总结+例题
学了数位DP很久了,今天就简单的总结一下吧。一、什么是数位DP 数位DP简单来说是一种统计数的DP,该类题一般可以用暴力写出来,但是由于数据太大,一般会超时。数位DP一般是统计[l,r]中满足题中要求的数的个数,至于为什么称为数位DP,因为要对数的每一位进行讨论(个位,十位,百位……)。数位DP一般有两种写法,一种是循环,另一种是递归。通常用循环写,比较的麻烦,所以我们一般都是用递归来写...原创 2019-02-23 16:38:12 · 1205 阅读 · 0 评论 -
lower_bound和upper_bound求最长上升(不下降)子序列O(nlogn)做法。
解决的问题:给定一个序列,求最长不下降子序列的长度(nlogn的算法没法求出具体的序列是什么)定义:a[1..n]为原始序列,dp[k]表示长度为k的不下降子序列末尾元素的最小值,len表示当前已知的最长子序列的长度。O(logn)的复杂度维护,实际上利用了dp数组的一个性质:单调性(因为我们本来就要求的一个不下降或上升子序列,虽然dp数组长度变,但是dp数组还是一个递增数组)。...原创 2018-07-11 15:05:09 · 1856 阅读 · 0 评论 -
HDU2571 命运(记忆化搜索)
穿过幽谷意味着离大魔王lemon已经无限接近了! 可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个机关。要知道,不论何人,若在迷宫中被困1小时以上,则必死无疑! 可怜的yifenfei为了去救MM,义无返顾地跳进了迷宫。让我们一起帮帮执着的他吧! 命运大迷宫可以看成是一个两维的方格阵列,如下图所示: yifenfei一开始在左...原创 2018-07-08 18:35:37 · 206 阅读 · 0 评论 -
ACM DP入门题(附代码解释)
目录HDU 1171 Big Event in HDU(多重背包)HDU 1224 Free DIY TourHDU 1421 搬寝室HDU1069 Monkey and Banana(DAG模型)HDU1506 Largest Rectangle in a HistogramHDU 1257 最少拦截系统 (最长上升子序列)HDU 1505 City GameHD...原创 2019-08-15 22:33:16 · 2144 阅读 · 0 评论