
———其他dp
MissZhou要努力
不晓日月,不辩兰艾,终日碌碌,安与燕雀相随乎
展开
-
CF414B、CF415DMashmokh and ACM【二维DP】
从昨天晚上开始紧张的这次周赛居然全是div1的题真是醉了,就连现在引以为豪的DP都做不出来T^T 简单说说这个题的思路,其实最开始想到是DP一类的了,但是也没推对orz,二维的DP嘛,一定要考虑一下,两个维度表示的意义:当前所在的长度、当前长度可以存在的数字,每次递推由上一状态(当前长度-1)得来,判断当前可能的方案数就是在原来基础上相加得到。贴代码:#include #include原创 2015-12-01 21:02:36 · 651 阅读 · 0 评论 -
hdu1160FatMouse's Speed DP
Problem DescriptionFatMouse 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 p原创 2015-09-15 21:41:17 · 470 阅读 · 0 评论 -
hdu1421搬寝室 DP
Problem Description搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度原创 2015-09-14 09:34:05 · 581 阅读 · 0 评论 -
2015多校联合第四场hdu5327Olympiad 递推
Problem DescriptionYou are one of the competitors of the Olympiad in numbers. The problem of this year relates to beatiful numbers. One integer is called beautiful if and only if all of its digita原创 2015-09-10 20:48:53 · 563 阅读 · 0 评论 -
2015多校联合第六场hdu5375Gray code
DescriptionThe reflected binary code, also known as Gray code after Frank Gray, is a binary numeral system where two successive values differ in only onebit (binary digit). The reflected binary co原创 2015-09-07 21:32:37 · 611 阅读 · 0 评论 -
2015多校联合第八场hdu5389Zero Escape DP
Problem DescriptionZero Escape, is a visual novel adventure video game directed by Kotaro Uchikoshi (you may hear about ever17?) and developed by Chunsoft.Stilwell is enjoying the first chapte原创 2015-09-09 19:38:16 · 554 阅读 · 0 评论 -
nefu1018数组游戏2
普普通通的一个小DP,只不过变成了数字可以变成10-a,跟之前的什么穿越幽谷,步步惊心有什么区别==,为什么比赛的时候就没有想到是动态规划!!!而且 审题啊!!题里说n是10^6不是a是10^6啊!!RE了两次居然都没发现!!还有题中说“该操作选定一个区间,将区间内的数 改成 s = (10-s)”所以b=(10-a+'0')-a+'0';而不是做差再模10啊!!就不能原创 2015-08-01 23:03:45 · 403 阅读 · 0 评论 -
nefu993计数问题
我们把根节点去掉,得到m棵子树,这些子树的形状一定是相同的,而且节点数也一定相同,因此我们考虑 把(n-1)个节点分成m份,F[N]+=F((N-1)/M),因为要平均分,所以M是N-1的约数有一颗又n个节点的树形态不固定。我们对它的形态只有一个要求,那就是同一层的节点所跟的孩子的数目相同,问这个数有多少种形态,结果对1000000007取模 Input每行原创 2015-08-01 22:46:52 · 369 阅读 · 0 评论 -
CodeForces 676B Pyramid of Glasses【杨辉三角倒鸡尾酒】
SubmitStatusPracticeCodeForces 676BDescriptionMary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so th原创 2016-06-12 15:20:10 · 891 阅读 · 0 评论 -
弱校联萌十一大决战之厉兵秣马H. Hanoi Towers poj3572
The “Hanoi Towers” puzzle consists of three pegs (that we will name A, B, and C) with n disks of different diameters stacked onto the pegs. Initially all disks are stacked onto peg A with the smalle原创 2015-10-06 11:05:17 · 971 阅读 · 4 评论 -
最大礼物价值 【二维dp 记忆化搜索】 特别水
在一个mXn的棋盘的每一个格子都放有一个礼物,每个礼物都有一定的价值(价值大于0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向左或者向下移动一格。直到到达棋盘的右下角。给定一个前以及其上面的礼物,请计算你最多能拿到多少价值的礼物。不喜欢递归……师兄问起来,墨迹了一个多小时才写出来……菜的一逼 鄙视自己orz#include <iostream>#include<cstd...原创 2018-03-08 12:10:03 · 379 阅读 · 0 评论 -
hdu1506Largest Rectangle in a Histogram
Problem DescriptionA histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the fi原创 2015-09-16 20:47:13 · 714 阅读 · 0 评论 -
hdu1505city game dp
Problem DescriptionBob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees原创 2015-09-17 09:41:05 · 630 阅读 · 0 评论 -
nefu1018数字游戏二【DP】
description有一个长度为n,由数字[0,9]组成的串。我们至多对其进行一次操作,该操作选定一个区间,将区间内的数 改成 s[i] = (10-s[i])%10 (l<=ii<=r);求s[0]+s[1]+……+s[n-1] 的最大值。input输入一个n (1<=n<=1000 000)原创 2015-09-21 21:37:33 · 438 阅读 · 0 评论 -
BestCoder Round #63 (div.2)1003 matrix
好兴奋水了一发DP ~可以根据位置判断当前步数的奇偶性,然后奇数的dp值储存前一个的最小值,偶数的dp值储存现在的整个式子的总和~感觉之前的DP没白练虽然也有挺多人A了 但是好歹这次进前200了 rate终于能涨点了 倒是挺后悔为啥没早点做 还有10分钟 应该是挤不出200的贴出来光荣的代码 其实有一个地方可以优化一下的:最开始的dp值全设成无穷大就不用判断i,j是否等于1原创 2015-11-21 21:02:49 · 484 阅读 · 0 评论 -
poj3071football【概率DP】
这个题已经搁浅太久 dp[i][j]表示第i轮的时候,第j去支队伍赢的概率。那么dp[i][j]的前提就是i-1轮的时候,j是赢的,而且第i轮赢了对方接下来就是找到第i轮的时候,他的可能队手通过二进制可以发现规律,所有高位是一样的,第i位刚好相反,所以用位运算可以巧妙解决,见代码dp[i][j]=sigma(dp[i-1][j]*dp[i-1][k]*p原创 2015-10-14 21:36:18 · 485 阅读 · 0 评论 -
hdu4405Aeroplane chess【概率DP】
Problem DescriptionHzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal pr原创 2015-10-13 18:39:40 · 522 阅读 · 0 评论 -
poj2096Collecting Bugs【概率DP】
DescriptionIvan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possib原创 2015-10-12 16:48:55 · 437 阅读 · 0 评论 -
hdu1466计算直线的交点数&2050 折线分割平面【DP】
Problem Description平面上有n条直线,且无三线共点,问这些直线能有多少种不同交点数。比如,如果n=2,则可能的交点数量为0(平行)或者1(不平行)。 Input输入数据包含多个测试实例,每个测试实例占一行,每行包含一个正整数n(n Output每个测试实例对应一行输出,从小到大列出所有相交方案,其中每个数为可能的交点数,每行的整数之间用原创 2015-10-08 19:37:50 · 695 阅读 · 0 评论 -
hdu4323magic number【编辑距离dp】
Problem DescriptionThere are many magic numbers whose lengths are less than 10. Given some queries, each contains a single number, if the Levenshtein distance (see below) between the number in the q原创 2016-03-27 19:03:01 · 459 阅读 · 0 评论 -
hdu4314Save the dwarfs【dp】
Problem DescriptionSeveral dwarfs are trapped in a deep well. They are not tall enough to climb out of the well, so they want to make a human-pyramid, that is, one dwarf stands on another's shoulder原创 2016-03-19 17:56:30 · 482 阅读 · 0 评论 -
poj3666Making the Grade【dp离散化】
居然沦落到不到40行的dp还要翻题解你想咋的 这题可能唯一难就难在离散化做的少,就算告诉了状态转移方程也写不好,再说了,状态转移方程也不难啊,换到这个题就换了一个地方而已啊方程:dp[i][j]=abs(j-a[i])+mn i表示递推到哪位,j表示目前的最大值(这题数据只要满足不递减就可以了),mn表示前面一位的各个最大值时的花费最小值。然后离散化的思想是既然给的数据单个的值都那么大,那我原创 2016-02-05 11:46:08 · 714 阅读 · 0 评论 -
CodeForces 424D Biathlon Track【二维dp】
DescriptionRecently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoro原创 2015-12-30 15:47:31 · 724 阅读 · 0 评论 -
hdu1003max sum【DP】
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5原创 2015-10-03 19:05:59 · 498 阅读 · 0 评论 -
Wannafly挑战赛12C 删除子串【dp】
本来上周五是想好好做就算没有奖金最差没准能混一个校招直通,piapiapia打脸啊 ( ̄ε(# ̄)☆╰╮( ̄▽ ̄///)最开始的想法是尽可能的删掉连续的a或者b,还大费周折的预处理成数组形式orz看到对象AC的代码,昨天晚上又拽着讲了一遍,基本上是明白了dp[i][j][k] i表示递推到哪位 j表示当前变化了多少 需要从1~m+1因为这种写法默认一开始就有变化的k 0当前状态下没有字符 1结尾...原创 2018-03-27 09:32:33 · 210 阅读 · 1 评论