
普通dp
junior19
abcde
展开
-
Leetcoder 887. Super Egg Drop(动态规划)
题意:给K个鸡蛋,有N层楼,问至少要多少次扔鸡蛋才能保证找出摔破鸡蛋的临界楼层,鸡蛋碎了就没了。思路:首先题意要搞清楚,是要保证能找出临界点,也就是你采取的方案无论临界点在哪一层,都必须在扔这么多次之内找出来。方法一:dp[i][j]表示剩余i个鸡蛋处理j层楼至少要扔几次,那么怎么推理dp[i][j]呢?枚举第一个鸡蛋扔的楼层(1~j),假设扔到了第k层,碎了,转移到dp[i-1][k-1...原创 2019-08-26 14:24:43 · 430 阅读 · 0 评论 -
CFgym:Teamwork(dp & 过河问题)
Teamwork is highly valued in the ACM ICPC. Since the beginning, the ICPC has distinguished itself from other programming contests in that teamwork is a key factor.The University of Beijing, host of原创 2017-11-26 20:46:51 · 536 阅读 · 0 评论 -
BZOJ1046:上升序列(LIS & dp)
1046: [HAOI2007]上升序列Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 5425 Solved: 1883[Submit][Status][Discuss]Description 对于一个给定的S={a1,a2,a3,…,an},若有P={ax1,ax2,ax3,…,axm},满足(x1 2 出S序原创 2017-12-10 00:03:44 · 265 阅读 · 0 评论 -
ARC085:F - NRE(线段树 & dp)^
F - NRETime limit : 3sec / Memory limit : 256MBScore : 1000 pointsProblem StatementYou are given a sequence a={a1,…,aN} with all zeros, and a sequence b={b1,…,bN} consisting of原创 2017-11-20 21:15:38 · 628 阅读 · 0 评论 -
CodeChef:Girl Friend and String Gift(dp)
Chef's Girl Friend has given him a unique gift. She has given him a string S. Chef being a gentleman wants to return her gift in a unique way. He wants to break the string he has received into some nu原创 2017-09-15 22:03:17 · 294 阅读 · 0 评论 -
CodeChef:Good Pairs(dp & 二进制)
You are given N integers: A1, A2, ..., AN. You need to count the number of pairs of indices (i, j) such that 1 ≤ i j ≤ N and Ai | Aj ≤ max(Ai, Aj).Note: Ai | Aj refers to bitwise OR.Inpu原创 2017-08-15 23:00:08 · 420 阅读 · 0 评论 -
HDU1530:Maximum Clique(最大团)
Maximum CliqueTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4546 Accepted Submission(s): 2392Problem DescriptionGiven a g原创 2017-08-06 22:25:09 · 429 阅读 · 0 评论 -
POJ2137:Cowties(dp)
CowtiesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3262 Accepted: 1125DescriptionN cows (3 Each cow has a number of grazing spots she likes an原创 2017-08-17 23:28:47 · 286 阅读 · 0 评论 -
CF821E:Okabe and El Psy Kongroo(dp & 矩阵)
E. Okabe and El Psy Kongrootime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOkabe likes to take walks but k原创 2017-07-24 16:26:04 · 1173 阅读 · 0 评论 -
BZOJ4361:isn(非降序列 & dp & 容斥)
4361: isnTime Limit: 10 Sec Memory Limit: 256 MBSubmit: 401 Solved: 199[Submit][Status][Discuss]Description给出一个长度为n的序列A(A1,A2...AN)。如果序列A不是非降的,你必须从中删去一个数,这一操作,直到A非降为止。求有多少种不同的操作方案,答案模10^9+7。Input第一行原创 2018-01-02 15:16:33 · 521 阅读 · 0 评论 -
BZOJ2298:problem a(dp线段覆盖 & 思维)
2298: [HAOI2011]problem aTime Limit: 10 Sec Memory Limit: 256 MBSubmit: 1572 Solved: 785[Submit][Status][Discuss]Description一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低。”问最少有几个人没有说真话(可能有相同的分数)原创 2018-01-12 17:02:26 · 413 阅读 · 0 评论 -
51nod1680:区间求和(BIT & dp)
有n个数,给定一个k,求所有长度大于等于k的区间中前k大数的总和。这样就比较简单相信大家都会,所以此题要求当k=1~n的总和,即求 ∑nk=1∑n−k+1i=1∑nj=i+k−1 区间前K大和Input输入五个数n,a1,A,B,C。a1表示第一个数,A,B,C用来生成其余n-1个数。a(i)=(a(i-1)*A+B)mod C。1Output原创 2018-02-01 17:51:43 · 537 阅读 · 0 评论 -
HDU6415:Rikka with Nash Equilibrium(dp)
Problem DescriptionNash Equilibrium is an important concept in game theory.Rikka and Yuta are playing a simple matrix game. At the beginning of the game, Rikka shows an n×m integer matrix A. And th...原创 2018-08-20 18:41:43 · 492 阅读 · 0 评论 -
USACO16FEB:再探圆形谷仓(dp)
题目描述After the last debacle involving Farmer John's circular barn, one would think he had learned his lesson about non-traditional architecture. However, he thinks he can still make his circular barn...原创 2018-08-09 00:12:55 · 719 阅读 · 0 评论 -
ATCODER:Or Plus Max(二进制递推)
E - Or Plus MaxTime limit : 2sec / Memory limit : 1024MBScore : 700 pointsProblem StatementThere is an integer sequence of length 2N: A0,A1,…,A2N−1. (Note that the sequence is 0-indexed.)For every int...原创 2018-07-11 20:46:41 · 546 阅读 · 0 评论 -
CODECHEF:Change the Signs(dp & 思维)
You are given a sequence of integers A1,A2,…,ANA1,A2,…,AN.You should choose an arbitrary (possibly empty) subsequence of AA and multiply each element of this subsequence by −1−1. The resulting sequenc...原创 2018-07-02 19:51:33 · 338 阅读 · 0 评论 -
ZOJ3605:Find the Marble(普通dp)
Alice and Bob are playing a game. This game is played with several identical pots and one marble. When the game starts, Alice puts the pots in one line and puts the marble in one of the pots. After th...原创 2018-05-03 00:18:21 · 166 阅读 · 0 评论 -
hrbustOJ 2372:小L的问题(矩阵快速幂 dp)
小L的问题Time Limit: 1000 MSMemory Limit: 256000 KTotal Submit: 52(17 users)Total Accepted: 12(7 users)Rating: Special Judge: NoDescription小L是一个可爱的女孩,她特别喜欢玩多米诺骨牌。有一天她得到了一个宽度为2长度为n的棋盘。她现在有1*2大小的矩形骨牌和3格大小的L...原创 2018-03-26 19:33:51 · 466 阅读 · 0 评论 -
51nod1815:调查任务(强连通 & dp)^
1815 调查任务 基准时间限制:4 秒 空间限制:524288 KB 分值: 80 难度:5级算法题 收藏 关注lbn是战忽中心——一个绝密的军事组织的一个军官,今天他接到了一个紧急任务:调查敌国X国某些城市的经济情况。X国有N个城市,由M条单向道路连接,其中S城是X国的首都。每个城市i有一个发达指数a[i],我们定义城市i的经济状况为首都S到城市i任意一条路径上两个不同的城市x,y的a[x] ...原创 2018-02-24 18:29:31 · 483 阅读 · 0 评论 -
CSA:Count Arrays(dp)
Count ArraysTime limit: 1000 msMemory limit: 256 MBYou are given QQ segments. For every 1 \le i \le Q1≤i≤Q, segment number ii is [l_i,r_i][li,ri].A binary array of length NN is considered good i...原创 2018-03-02 16:13:10 · 293 阅读 · 0 评论 -
CF825F:String Compression(dp & kmp)
F. String Compressiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIvan wants to write a letter to his f原创 2017-07-22 00:57:20 · 441 阅读 · 0 评论 -
CF797F:Mice and Holes(dp + 单调队列优化)
F. Mice and Holestime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Masha came home and noticed n m原创 2017-05-10 22:51:00 · 1278 阅读 · 0 评论 -
GDUT1165: zas的二进制(简单dp)
1165: zas的二进制Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 88 Solved: 39Descriptionzas最近在玩一种特别的二进制数,它没有前导零且只由1和0组成,并且没有连续的1相邻在一起,例如前几个就是1,10,100,101,1000,1001,1010,10000.现在zas问jzr长原创 2017-03-17 22:23:12 · 23889 阅读 · 0 评论 -
HDU1069:Monkey and Banana(dp)
Monkey and BananaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13646 Accepted Submission(s): 7194Problem DescriptionA group原创 2017-02-22 16:45:47 · 277 阅读 · 0 评论 -
POJ1189:钉子和小球(dp)
钉子和小球Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7903 Accepted: 2420Description有一个三角形木板,竖直立放,上面钉着n(n+1)/2颗钉子,还有(n+1)个格子(当n=5时如图1)。每颗钉子和周围的钉子的距离都等于原创 2017-02-21 19:15:13 · 276 阅读 · 0 评论 -
HDU1028:Ignatius and the Princess III(dp入门 & 母函数)
Ignatius and the Princess IIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19924 Accepted Submission(s): 13936Problem Descripti原创 2017-01-23 14:38:16 · 224 阅读 · 0 评论 -
CF416B:Art Union(dp)
B. Art Uniontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA well-known art union called "Kalevich is Aliv原创 2017-02-21 14:14:05 · 333 阅读 · 0 评论 -
HDU2151:Worm(简单dp)
WormTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4067 Accepted Submission(s): 2602Problem Description自从见识了平安夜苹果的涨价后,Lele就在原创 2017-02-20 22:14:09 · 300 阅读 · 0 评论 -
HDU2059:龟兔赛跑(dp)
reference:http://blog.youkuaiyun.com/lvshubao1314/article/details/20151841龟兔赛跑Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17928 Accep原创 2017-02-20 22:02:07 · 296 阅读 · 0 评论 -
CF467C: George and Job(dp)
C. George and Jobtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe new ITone 6 has been released recently原创 2017-02-10 23:09:41 · 349 阅读 · 0 评论 -
51nod1055: 最长等差数列(dp)
1055 最长等差数列基准时间限制:2 秒 空间限制:262144 KB 分值: 80 难度:5级算法题 收藏 关注N个不同的正整数,找出由这些数组成的最长的等差数列。例如:1 3 5 6 8 9 10 12 13 14等差子数列包括(仅包括两项的不列举)1 3 51 5 9 133 6 9 123转载 2017-03-09 22:52:06 · 547 阅读 · 0 评论 -
GDUT2017校赛:Problem C: 爬楼梯(DP)
Problem C: 爬楼梯Description小时候,我只能一阶一阶得爬楼梯,后来,我除了能一次爬一阶,还可以一次爬两阶,到现在,我最多一次可以爬三阶。那么现在问题来了,我想爬上n层楼,相邻楼层之间有一段楼梯,虽然我一次可以爬1个台阶、2个台阶和3个台阶,但是我在i与i+1层之间的楼梯上时,我不能跨越到i+1与i+2层之间的楼梯。现在有个原创 2017-03-27 23:24:14 · 857 阅读 · 0 评论 -
HDU4545:魔法串(DP)
魔法串Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2671 Accepted Submission(s): 965Problem Description 小明和他的好朋友小西在玩一个新的游戏,由小原创 2017-03-29 22:41:52 · 278 阅读 · 0 评论 -
CFgym:Memory Manager(dp & 单调队列优化)
"D" Memory ManagerTime limit3 secondsMemory limit256 megabytesPeter is developing memory manager MEM 2.0 for his offline storage that uses special magnetic 7D原创 2017-07-16 21:50:42 · 301 阅读 · 0 评论 -
UVA10237:Bishops(dp)
题意:N*N的表格,给K只棋子放进去,要求同一斜线上至多有一只棋子,求方案数。思路:首先将棋盘转45°,就变成横竖的问题了,显然奇数行和偶数行是无冲突的,考虑分开计算,到时候用乘法原理加起来即可,尽管每一行的格子数先增后减,将短的行先计算也无影响,又显然奇数行比偶数行多1行,最后要再计算一次。dp[i][j] = dp[i-1][j](这行不放) + dp[i-1][j-1]*(line[i]原创 2017-06-14 15:05:34 · 405 阅读 · 0 评论 -
CF799D:Field expansion(dp)
D. Field expansiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn one of the games Arkady is fond of the原创 2017-05-19 22:32:45 · 2147 阅读 · 0 评论 -
CF811C:Vladik and Memorable Trip(dp)
C. Vladik and Memorable Triptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVladik often travels by trains原创 2017-05-31 13:39:29 · 901 阅读 · 0 评论 -
AtCoder:Infinite Sequence(dp)
F - Infinite SequenceTime limit : 2sec / Memory limit : 256MBScore : 1000 pointsProblem StatementHow many infinite sequences a1,a2,… consisting of {1,…,n} satisfy the following c原创 2017-05-13 13:59:58 · 449 阅读 · 0 评论 -
HIT15:Birthday Party(dp)
J - J - Birthday PartyTime limit : 1 sMemory limit : 512 mbSubmitted : 53Accepted : 1964bit Integer Format : %lldSubmitProblem Descrip原创 2017-05-04 13:48:23 · 214 阅读 · 0 评论 -
HDU4055:Number String(DP)
reference:http://blog.youkuaiyun.com/jayye1994/article/details/12361481Number StringTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1945原创 2017-04-05 23:46:42 · 255 阅读 · 0 评论