
dp
Baiyi_destroyer
记录过,回望来时路
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
饭卡(基础dp)
Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Input多组数据。对于每组数据: 第一...原创 2018-06-04 19:28:39 · 336 阅读 · 0 评论 -
一卡通大冒险(hdu 2512 )
因为长期钻研算法, 无暇顾及个人问题,BUAA ACM/ICPC 训练小组的帅哥们大部分都是单身。某天,他们在机房商量一个绝妙的计划"一卡通大冒险"。这个计划是由wf最先提出来的,计划的内容是,把自己的联系方式写在校园一卡通的背面,然后故意将自己的卡"遗失"在某处(如水房,TD,食堂,主M。。。。)他们希望能有MM看到他们遗失卡,能主动跟他们联系,这样就有机会请MM吃饭了。他们决定将自己的一卡通夹...原创 2018-07-25 20:35:49 · 895 阅读 · 0 评论 -
Discovering Gold (lightoj 1030 概率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...原创 2018-07-28 10:29:33 · 183 阅读 · 0 评论 -
Throwing Balls into the Baskets (Light OJ 1317 概率dp)
You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the g...原创 2018-07-28 10:32:43 · 220 阅读 · 0 评论 -
Island of Survival ( LightOJ1265 概率dp)
You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, ...原创 2018-07-28 10:37:42 · 526 阅读 · 0 评论 -
Dice (III) (light oj 1248 概率dp)
Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dic...原创 2018-07-28 10:41:46 · 335 阅读 · 0 评论 -
划分树详解及模板
感谢语海与冰大佬的帮助!!!看了一些博客,感觉有些博客对建树写的挺好,但是对于查询区间却一笔带过。在看懂了之后决定自己写一篇,加深自己的理解,也希望对正在学习划分树的人能够有所帮助。 如有错误,敬请大佬指出。进入正题:有这样一类题目,求的是区间内的第k大数。划分树的定义就是对整体的区间进行划分,把相对于原来序列中较小的值放在左子树,较大的放在右子树,最后按照它的性质进行查询以此找...转载 2018-08-07 15:39:03 · 242 阅读 · 0 评论 -
数位dp讲解
转载自:传送门 数位DP其实是很灵活的,所以一定不要奢求一篇文章就会遍所有数位DP的题,这一篇只能是讲清楚一种情况,其他情况遇到再总结,在不断总结中慢慢体会这个思想,以后说不定就能达到一看到题目就能灵活运用的水平。(其实DP都是这样……)这一篇要说的数位DP是一道最简单的数位DP:题目链接题目大意:多组数据,每次给定区间[n,m],求在n到m中没有“62“或“4“的数的个数。 ...转载 2018-08-03 10:59:33 · 317 阅读 · 0 评论 -
数位dp总结 之 从入门到模板(转)
转自:https://blog.youkuaiyun.com/wust_zzwh/article/details/52100392基础篇数位dp是一种计数用的dp,一般就是要统计一个区间[le,ri]内满足一些条件数的个数。所谓数位dp,字面意思就是在数位上进行dp咯。数位还算是比较好听的名字,数位的含义:一个数有个位、十位、百位、千位......数的每一位就是数位啦! 之所以要引入数位的概念...转载 2018-08-03 14:56:23 · 193 阅读 · 0 评论 -
背包九讲(转)
转自dd大牛的《背包九讲》 目录第一讲 01背包问题第二讲 完全背包问题第三讲 多重背包问题第四讲 混合三种背包问题第五讲 二维费用的背包问题第六讲 分组的背包问题第七讲 有依赖的背包问题第八讲 泛化物品第九讲 背包问题问法的变化附:USACO中的背包问题 前言本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个...转载 2018-10-04 10:32:45 · 300 阅读 · 0 评论 -
Balls(UVALive 4554,dp)
DescriptionThe classic Two Glass Balls brain-teaser is often posed as: “Given two identical glass spheres, you would like to determine the lowest floor in a 100-story buil...原创 2018-10-14 15:06:48 · 314 阅读 · 0 评论 -
Adjacent Bit Counts(UVALive 4557,三维dp)
DescriptionFor a string of n bits x1, x2, x3,…, xn, the adjacent bit count of the string (AdjBC(x)) is given by x1 ∗ x2 + x2 ∗ x3 + x3 ∗ x4 + . . . + xn...原创 2018-10-14 15:20:11 · 228 阅读 · 0 评论 -
Working out(CodeForces 429B,dp)
DescriptionSummer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i...原创 2018-10-17 20:39:38 · 260 阅读 · 0 评论 -
m-ary Partitions(UVALive 7785)
DescriptionA partition of an integer n is a set of positive integers which sum to n, typically written in descendingorder. For example:10 = 4+3+2+1A partition is m-ary if each term in the partit...原创 2018-11-12 20:30:20 · 555 阅读 · 0 评论 -
Permutation Descent Counts(UVALive 7787)
DescriptionGiven a positive integer, N, a permutation of order N is a one-to-one (and thus onto) function fromthe set of integers from 1 to N to itself. If p is such a function, we represent the fu...原创 2018-11-14 19:59:24 · 345 阅读 · 0 评论 -
FATE
最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?Inp...原创 2018-07-19 21:08:27 · 460 阅读 · 0 评论 -
最大报销额
现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。 Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数 Q 和 N,其中 Q 是给定的报销额度,N(<=30...原创 2018-07-19 18:57:24 · 200 阅读 · 0 评论 -
Super Jumping! Jumping! Jumping! (hdu 1087)
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 ...原创 2018-07-25 11:17:18 · 250 阅读 · 0 评论 -
Bone Collector(01背包)
DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave … The bone...原创 2018-06-04 19:33:27 · 320 阅读 · 0 评论 -
DP方程及意义
01背包有N件物品和一个容量为V的背包。第i件物品的费用(即体积,下同)是w[i],价值是c[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。基本思路: 这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。 用子问题定义状态:即f[i][v]表示前i件物品(部分或全部)恰放入一个容量为v的背包可以获得的最大价值。 则其状态转移方程便...转载 2018-06-04 20:49:31 · 1029 阅读 · 0 评论 -
HDU 2084 数塔(简单DP)
Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行...原创 2018-06-22 20:28:02 · 197 阅读 · 0 评论 -
一只小蜜蜂... (hdu 2044)
有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。 其中,蜂房的结构如下所示。 Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)。 Output对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。 Sam...原创 2018-07-18 15:45:20 · 201 阅读 · 0 评论 -
不容易系列之(3)—— LELE的RPG难题 (hdu 2045)
人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即"可乐"),经过多方打探,某资深Cole终于知道了原因,原来,LELE最近研究起了著名的RPG难题: 有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法. 以上就是著名的RP...原创 2018-07-18 15:57:22 · 177 阅读 · 0 评论 -
阿牛的EOF牛肉串 (hdu 2047)
今年的ACM暑期集训队一共有18人,分为6支队伍。其中有一个叫做EOF的队伍,由04级的阿牛、XC以及05级的COY组成。在共同的集训生活中,大家建立了深厚的友谊,阿牛准备做点什么来纪念这段激情燃烧的岁月,想了一想,阿牛从家里拿来了一块上等的牛肉干,准备在上面刻下一个长度为n的只由"E" "O" "F"三种字符组成的字符串(可以只有其中一种或两种字符,但绝对不能有其他字符),阿牛同时禁止在串中出现...原创 2018-07-18 16:01:43 · 130 阅读 · 0 评论 -
不容易系列之(4)——考新郎 (hdu 2049)
国庆期间,省城HZ刚刚举行了一场盛大的集体婚礼,为了使婚礼进行的丰富一些,司仪临时想出了有一个有意思的节目,叫做"考新郎",具体的操作是这样的: 首先,给每位新娘打扮得几乎一模一样,并盖上大大的红盖头随机坐成一排; 然后,让各位新郎寻找自己的新娘.每人只准找一个,并且不允许多人找一个. 最后,揭开盖头,如果找错了对象就要当众跪搓衣板... 看来做新郎也不是容易的事情... 假设一共有N...原创 2018-07-18 16:06:35 · 227 阅读 · 0 评论 -
折线分割平面 (hdu 2050)
我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。 Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。 Output对于每个测试实例,请输出平面...原创 2018-07-18 16:13:08 · 305 阅读 · 0 评论 -
Number String (hdu 4055)
The signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutation, write down the letter 'I' (increasing) if the second element is greate...原创 2018-07-19 08:28:08 · 320 阅读 · 0 评论 -
Common Subsequence(HDU 1159,最长公共子序列)
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subs...原创 2018-07-24 16:04:58 · 197 阅读 · 0 评论 -
Advanced Fruits(HDU1503)
Problem DescriptionThe company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn...原创 2018-07-24 16:20:12 · 233 阅读 · 0 评论 -
最少拦截系统 (HDU 1257)
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统...原创 2018-07-24 16:27:51 · 195 阅读 · 0 评论 -
Bridging signals (POJ 1631 HDU 1950)
'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...原创 2018-07-24 16:38:17 · 291 阅读 · 0 评论 -
FatMouse's Speed (hdu 1160)
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...原创 2018-07-25 11:10:21 · 269 阅读 · 0 评论 -
Counting substhreengs(UVALive 6823)
DescriptionSubstrings are strings formed by choosing a subset of contiguous characters from a string. This is wellknown. A little more obscure is the definition of substhreengs. A substhreeng is a ...原创 2018-11-30 20:30:49 · 630 阅读 · 0 评论