
DP
文章平均质量分 82
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
HDU 1024 Max Sum Plus Plus(最大m子段和)
Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem. Given ...原创 2018-05-21 21:58:13 · 401 阅读 · 0 评论 -
冰水挑战 HDU - 6495
Polar Bear Pitching helps you crystallize your message.The stage could not be any cooler, and we mean literally:a hole cut through the ice in the frozen Baltic Sea.2050有一项很有挑战的活动 —— Polar Bear P...原创 2019-04-19 11:06:09 · 392 阅读 · 0 评论 -
Flood Fill CodeForces - 1114D
You are given a line ofnncolored squares in a row, numbered from11tonnfrom left to right. Theii-th square initially has the colorcici.Let's say, that two squaresiiandjjbelong to the same...原创 2019-04-19 16:43:30 · 210 阅读 · 0 评论 -
问题 I: Winner Winner
The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Training Center of Fuzhou University. The activity mainly includes the programming contest like ACM-ICPC and strive to provide...原创 2019-05-05 20:05:23 · 415 阅读 · 0 评论 -
牛客暑假多校训练第一场 E ABBA
思路: 设dp[i][j]表示有i个A,j个B的方法数。考虑递推方程: 当i<n+j时可以放A(如果A的个数i小于n或者放的’B‘的个数j小于多出来的’A’ 则可以直接放i)得到递推式: dp[i+1][j]+=dp[i][j]同理 知: j<m+i可以放B 递推式:dp[i][j+1]+=dp[i][j]#in...原创 2019-07-19 13:55:28 · 134 阅读 · 0 评论 -
最长上升子序列(LIS)两种写法
法一:DP 复杂度O(n)#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#define ll long longusing namespa...原创 2019-09-22 11:13:01 · 163 阅读 · 0 评论 -
2019牛客国庆集训派对day1 -I 2019
思路:dp[i][j]表示点 i 的子节点到点 i 的距离mod 2019 = j的路径个数。设一点为u,其子节点为v,u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][(j-w+2019)%2019];#include <iostream>#include<cstdio>#include<cstring>#include<a...原创 2019-10-05 09:53:27 · 429 阅读 · 0 评论 -
D.Modulo Nine (DP)
思路:若要a1*a2*a3....*an能mod9等于0,则该算式中必有两个因子3相乘或者含有0。对于一个右端点r,有多个[l,r]的时候,只要最小的那个区间满足,其他肯定都满足了。这样对于一个右端点的限制条件是否满足,取决于前面出现的最后两个3出现的位置(9和0算作两个3)由此我们设dp[i][j][k]表示前i个数,最后一个因子3出现的位置为j,倒数第二个为k。由于因子中含有3的数有3、...原创 2019-10-06 11:28:01 · 294 阅读 · 0 评论 -
I. Misunderstood … Missing (DP)
Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended ...原创 2019-10-06 15:27:04 · 732 阅读 · 0 评论 -
C. Colorful Bricks(dp)
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are原创 2019-04-17 19:55:51 · 366 阅读 · 0 评论 -
CodeForces - 859C. Pie Rules(思维+dp)
You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which ...原创 2019-04-17 17:41:18 · 436 阅读 · 0 评论 -
Assembly Required
题目描述Princess Lucy broke her old reading lamp, and needs a new one. The castle orders a shipment of parts from the Slick Lamp Parts Company, which produces interchangable lamp pieces.There are m typ...原创 2019-04-14 19:23:47 · 395 阅读 · 0 评论 -
最长上升子序列的两种算法(LIS)
最长上升子序列就是求:给定的一串数字中 找出不断上升的最长那一串(该串不一定相连,只保证递增即可)。就比如下面这个例子 其最长上升子序列为2 3 4 7或2 3 4 6 数串长度为4 那么具体怎么求的呢我们拿一个最简单的例子讲:【题目描述】给定N个数,求这N个数的最长上升子序列的长度。【样例输入】72 5 3 4 1 7 6【样例输出】4一、朴素算法 (复杂度O(n^2))dp[i]表示...原创 2018-05-24 08:48:01 · 645 阅读 · 0 评论 -
数位DP入门
数位DP顾名思义就是对数位运用DP思想,将每位数看成下一位的子状态,即个位看成十位的子状态,十位看成百位的子状态。下面给出状态方程:dp[i][j]=∑dp[i-1][k](k=0,1,2,3...9)dp[i][j] 表示i位数,首位是j的数字有多少符合要求的,我们从低位逐步递推求到高位。下面拿一道入门题来具体说明:HDU 2089 不要62传送门如何求满足要求的种类数呢,我们先不考虑62和4的...原创 2018-05-24 09:54:33 · 167 阅读 · 0 评论 -
抵制克苏恩
小Q同学现在沉迷炉石传说不能自拔。他发现一张名为克苏恩的牌很不公平。如果你不玩炉石传说,不必担心,小Q同学会告诉你所有相关的细节。炉石传说是这样的一个游戏,每个玩家拥有一个 30 点血量的英雄,并且可以用牌召唤至多 7 个随从帮助玩家攻击对手,其中每个随从也拥有自己的血量和攻击力。小Q同学有很多次游戏失败都是因为对手使用了克苏恩这张牌,所以他想找到一些方法来抵御克苏恩。他去求助职业炉石传说玩家椎名...原创 2018-12-24 22:08:11 · 167 阅读 · 0 评论 -
F. Tree with Maximum Cost
You are given a tree consisting exactly of原创 2019-01-21 15:12:47 · 377 阅读 · 1 评论 -
C. Ayoub and Lost Array(dp)
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 divisibl...原创 2019-01-26 11:27:28 · 270 阅读 · 0 评论 -
包子凑数 (exgcd+dp)
问题描述 小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子。每种蒸笼都有非常多笼,可以认为是无限笼。 每当有顾客想买X个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的...原创 2019-03-25 20:54:48 · 116 阅读 · 0 评论 -
Multiplying Digits(Dp+map)
For every positive integer we may obtain a non-negative integer by multiplying its digits. This defines a functionf, e.g.f(38) = 24.This function gets more interesting if we allow for other bases. ...原创 2019-04-15 21:47:29 · 302 阅读 · 0 评论 -
问题 D: Route Calculator(DP)
题目描述You have a grid with H rows and W columns. H+W is even. We denote the cell at the i-th row from the top and the j-th column from the left by (i,j). In any cell (i,j), an integer between 1 and 9 ...原创 2019-04-14 18:51:07 · 220 阅读 · 0 评论 -
codeforces161D. Distance in Tree(树形DP)
思路:dp[i][j]表示点 i 的子节点到点 i 的距离为j的路径个数。设一点为u,其子节点为v, u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][j-1];每个点对答案的贡献为:ans+=dp[u][j]*dp[v][(k-1-j)];#include <iostream>#include<cstdio>#include<c...原创 2019-10-08 10:24:40 · 141 阅读 · 0 评论