
----- D P ------
文章平均质量分 73
jerans
这个作者很懒,什么都没留下…
展开
-
qduoj 分辣条2
分辣条2发布时间: 2016年7月2日 21:47 最后更新: 2016年7月2日 21:51 时间限制: 1000ms 内存限制: 128M描述啊啊有根很大的辣条,重量为n,啊啊想把辣条分给很多小朋友,但是必须满足下列条件:1.每个小朋友分得的辣条重量为a,b或c;2.分得辣条的小朋友的数量最多;3.没有剩余的辣条,也就是说所有辣条都分完啦。原创 2016-11-03 13:26:46 · 466 阅读 · 0 评论 -
Gym - 100765I Mars Stomatology 二维dp好题
https://odzkskevi.qnssl.com/09c2b66468470898f860c2625578fbf4?v=1491547520题意大体是要医治一些牙,每一个牙龈上会有好多颗牙,治这颗牙的前提是把牙龈治好,治某个有对应的花费,治某颗牙有对应的花费跟julyc学的二维dp#include#include#include#include#include#incl原创 2017-04-22 23:43:28 · 317 阅读 · 0 评论 -
qduoj 帅气的HYC求乘积 dp//蓝桥算法训练 乘积最大
帅气的HYC求乘积发布时间: 2015年11月1日 17:02 最后更新: 2015年11月1日 18:38 时间限制: 1000ms 内存限制: 128M描述帅气的HYC饿了,于是他定了外卖,但是去拿外卖时却忘了带钱,这可怎么办?于是外卖小哥对他说,我也不为难你,我给你出个题,你要做出来就送你一份免费午餐。题目是这样的:设有一个长度N的数字串,要求你使原创 2017-04-24 23:44:13 · 320 阅读 · 0 评论 -
POJ - 3666 Making the Grade 二维dp
Making the GradeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7096 Accepted: 3282DescriptionA straight dirt road connects two fields on FJ's farm, b原创 2017-04-26 17:19:30 · 314 阅读 · 0 评论 -
Codeforces Round #417 (Div. 2)Sagheer, the Hausmeister 乱搞 Sagheer and Nubian Market 二分
B. Sagheer, the Hausmeistertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome people leave the lights at原创 2017-06-02 09:47:58 · 515 阅读 · 0 评论 -
51nod 1202 子序列的个数 dp
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=12021202 子序列个数题目来源: 福州大学 OJ基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注子序列的定义:对于一个序列a=a[1],a[原创 2017-07-15 14:25:41 · 408 阅读 · 0 评论 -
C - String painter HDU - 2476 区间dp
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2476.题意:两个字符串,操作:选取一段变为相同的字符,求有a串变为b串最小的操作次数先考虑从空串变为b串需要的最少操作次数dp[i] [j]表示i到j段变成b串需要的最少操作次数dp[i] [j] = min( dp[i+1] [k] + dp[k+1] [j])(其中k满足b[k]==b原创 2017-07-21 21:36:00 · 304 阅读 · 0 评论 -
Codeforces Round #426 (Div. 2) C. The Meaningless Game 思维 D. The Bakery dp
题目:http://codeforces.com/contest/834/problem/C题意:两个人玩游戏, 两个人初始值都为1,每次可以选一个正整数,一个人乘以这个正整数的平方,一个人乘以这个正整数,给你多对数,判断会不会出现这个游戏局面把ab乘起来,判断是不是一个数的三次方,并且是不是能被a和b整除k^3==a*b&&a%k==0&&b%k==0结果找k的二分写错了。。。。原创 2017-07-31 11:07:30 · 599 阅读 · 0 评论 -
hdu6078 wave sequence dp
http://acm.hdu.edu.cn/showproblem.php?pid=6078题意:#includeusing namespace std;const int maxn=2005;const int mo=998244353;long long dp[maxn][maxn][2],s[maxn][maxn][2],a[maxn],b[maxn];in原创 2017-08-08 11:53:55 · 252 阅读 · 0 评论 -
Codeforces Round #420 (Div. 2) E. Okabe and El Psy Kongroo 矩阵快速幂+dp
题目:http://codeforces.com/contest/821/problem/E递推方程很容易看出来,dp【i】【j】表示到达( i , j )这个点的路径条数dp【i】【j】=dp【i-1】【j+1】+dp【i-1】【j】+dp【i-1】【j-1】但k太大,肯定不能直接递推,快速幂优化一下,y的坐标范围是0~15,所以矩阵长度16就够了,至于c的限制,把转移矩阵的一些位置原创 2017-08-02 16:10:18 · 269 阅读 · 0 评论 -
hdu-5745 La Vie en rose bitset
http://acm.hdu.edu.cn/showproblem.php?pid=5745第一次使用bitset这个东西,优点是可以常数优化,而此题优雅的bitset转移刚好可以卡过转移方程是看的这篇博客,http://blog.youkuaiyun.com/u012015746/article/details/51992281“首先得出一个 dp式子,dp[i][j][k]表示 A原创 2017-09-04 13:40:08 · 335 阅读 · 0 评论 -
hdu 6170 Two strings dp
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6170#includeint dp[2505][2505];int n,m;char ch1[3000],ch2[3000];using namespace std;int main(){ int T,i,j; cin>>T; while(T--) {原创 2017-08-22 20:27:14 · 287 阅读 · 0 评论 -
HDU - 5860 Death Sequence 递推
每k个删掉一个,删掉之后对新序列继续这样的操作多次查询,求第m次是删掉了哪个位置的元素对于每个元素的下标是0~n-1(方便计算,1~n也可以),如果某个元素坐标 i 模 k 等于0则是现在要删掉的,否则会保留到下一轮,而到下一轮,新的位置是i-i/k-1而其实对于每一轮删的操作都是一样的,是不是也可以转化为,当前轮为i-i/k-1位置的元素删掉的轮次加一利用这个性质,就可以很好的O原创 2017-09-14 00:45:14 · 284 阅读 · 0 评论 -
Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom
人生的第一次div.1 掉分 QAQA - Planninghttp://codeforces.com/contest/853/problem/A贪心,排个序,优先安排花费大的,用模拟链表实现的#include#define eps 1e-9#define PI 3.141592653589793#define bs 1000000007#define bsize原创 2017-09-07 15:07:08 · 584 阅读 · 0 评论 -
hdu5791Two dp hdu5781ATM Mechine 概率dp hdu5787 K-wolf Number 数位dp
http://acm.hdu.edu.cn/showproblem.php?pid=5791很水的dp,是考虑复杂了考虑重复的转移方程dp【i】【j】= dp【i-1】【j】+ dp【i】【j】- dp【i-1】【j-1】#includeusing namespace std;const int mo=1e9+7;const int maxn=1005;long long原创 2017-09-08 02:21:53 · 371 阅读 · 0 评论 -
To My Girlfriend HDU - 5800 dp
那个式子可以想成有两个物品必拿,有两个物品必不拿,最后体积小于等于m的方案数也是同样想到了n^3的dp,必然会T,走进死沟,看了题解,才想到...不要考虑太多,对每个物品,有四种拿的状态,拿,必定拿,不拿,必定不拿这样就裸的转移就可以了#includeusing namespace std;int a[1005];long long dp[2][1005]原创 2017-09-17 00:40:52 · 238 阅读 · 0 评论 -
CodeForces - 372C Watching Fireworks is Fun dp
http://codeforces.com/problemset/problem/372/C题意:在一条街道上(线段),有m个烟花,给出每个烟花的位置和燃放的时间,以及一个b【i】值,当烟花燃放时,你在街道的x(1=b【i】-abs(a【i】-x),刚开始你可以在任意位置,之后可以移动你的位置,每秒可移动d个单位,求所有烟花燃放完之后的乐趣值最大值dp【i】【j】表示看完前i个烟花原创 2017-10-11 20:05:51 · 416 阅读 · 0 评论 -
hdu5492Find a path dp
http://acm.split.hdu.edu.cn/showproblem.php?pid=5492题意:一个n*m方格,每个格子上有自己的权值,从1,1出发每次只能 从(x, y) 走向(x + 1, y) 或 (x, y +1),终点n,m,路径长度必然就是n+m-1,求(N+M−1)∑N+M−1i=1(Ai−Aavg)2的的的的最小值,其中Ai是路径上的第i个权值,Aavg是原创 2017-10-14 19:33:28 · 262 阅读 · 0 评论 -
URAL - 2018 The Debut Album dp
2018. The Debut AlbumTime limit: 2.0 secondMemory limit: 64 MBPop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss yo原创 2017-04-30 19:09:57 · 342 阅读 · 0 评论 -
CodeForces - 148D. Bag of mice//Codeforces Round #105 (Div. 2)
D. Bag of micetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe dragon and the princess are arguing abou原创 2016-12-11 17:05:28 · 226 阅读 · 0 评论 -
Light OJ 1036A Refining Company
先用ma1[ i ][ j ] ,ma2[ i ][ j ]分别存从这个点往左和上运对应的矿可以运的重量maxx[ i ][ j ]代表这个 0 ~ i -- 0 ~ j 矩形可以运的最大矿量,递推公式mapp[ i ][ j ]=max(mapp[ i ][ j - 1 ]+ma2[ i ][ j ],mapp[ i - 1 ][ j ]+ma1[ i ][ j ])#include#原创 2016-11-27 16:18:55 · 344 阅读 · 0 评论 -
qduoj kkun和CerberuX
kkun和CerberuX发布时间: 2017年1月1日 15:11 最后更新: 2017年1月1日 15:16 时间限制: 2000ms 内存限制: 128M描述这一天kkun和CerberuX日常在玩游戏,这时候,他们发现了一个双人合作类游戏。给出一个n*m的地图,地图的每个格子都有分数,由kkun从左上角跑到右下角,CerberuX从左下角跑到原创 2017-01-05 16:07:46 · 524 阅读 · 0 评论 -
qduoj GZS采蘑菇
从前往后扫一遍,最水的dp。。#includelong long int a[1000005];int main(){ int t,n,i,max=0; scanf("%d",&t); while(t--) { max=0; scanf("%d",&n); for(i=0;i<n;i++) scanf("%lld",&a[i]); for(i=1;i<n;i+原创 2017-01-07 10:23:14 · 283 阅读 · 0 评论 -
F - Longest Ordered Subsequence POJ - 2533
Longest Ordered SubsequenceTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 49504 Accepted: 21978DescriptionA numeric sequence of ai is ordered if a1 a原创 2017-02-04 23:17:31 · 209 阅读 · 0 评论 -
POJ - 1159 Palindrome 最长公共子序列
PalindromeTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 61919 Accepted: 21576DescriptionA palindrome is a symmetrical string, that is, a原创 2017-02-05 23:20:25 · 368 阅读 · 0 评论 -
POJ - 1836 Alignment
AlignmentTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 16494 Accepted: 5406DescriptionIn the army, a platoon is composed by n soldiers. During the m原创 2017-02-07 21:44:29 · 280 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2)C. Mahmoud and a Message
C. Mahmoud and a Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud wrote a message s of lengt原创 2017-02-09 00:01:40 · 500 阅读 · 0 评论 -
Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率dp
D. Bad Luck Islandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Bad Luck Island is inhabited by thre原创 2017-02-18 20:44:16 · 594 阅读 · 0 评论 -
UVA - 674 Coin Change 多重背包or母函数
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=615题意是有五种面值不同的硬币,每种都可以用无限个,问组合成给定价值有多少种组合方法1.母函数求解,#include#include#include#include#incl原创 2017-03-08 20:37:29 · 288 阅读 · 0 评论 -
CodeForces - 365D D. Free Market
D. Free Markettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohn Doe has recently found a "Free Market" i原创 2017-03-08 21:32:46 · 674 阅读 · 0 评论 -
CodeForces - 361D Levko and Array二分加dp
D. Levko and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLevko has an array that consists of inte原创 2017-03-10 14:25:24 · 766 阅读 · 0 评论 -
CodeForces - 366C Dima and Salad
C. Dima and Saladtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima, Inna and Seryozha have gathered in a原创 2017-03-07 21:59:36 · 366 阅读 · 0 评论 -
URAL - 2072 Kirill the Gardener 3 dp
2072. Kirill the Gardener 3Time limit: 2.0 secondMemory limit: 64 MBKirill the gardener has got a new task. He has to water the flowers growing on the huge flowerbed! It should be mentio原创 2017-04-01 21:21:51 · 879 阅读 · 0 评论 -
UVALive - 5092 Permutation Counting
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3093很水的一个dp,但当时就没想出来。。。。。。。。。。。。。。。。。。。。。一直想着是添加一个大的元素,是插到之前的序列里,但这样没法确定“E”值的变化所以就用换的想法原创 2017-04-02 20:24:48 · 460 阅读 · 0 评论 -
ZOJ 3956 Course Selection System 01背包
Course Selection SystemTime Limit: 1 Second Memory Limit: 65536 KBThere are n courses in the course selection system of Marjar University. The i-th course is described by two values: ha原创 2017-04-12 20:30:22 · 1021 阅读 · 0 评论 -
Gym - 101128E E - Wooden Signs dp
https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337比较丑的做法第一维滚动数组,dp【0】【i】【j】 是指上一层,以i为起点,j为终点的情况数,#includeusing namespace std;long long int dp[2][2005][2005],mo=2原创 2017-03-27 13:18:55 · 502 阅读 · 0 评论 -
BZOJ 3566: [SHOI2014]概率充电器 概率dp
题目:点击打开链接树形概率dp,刚开始以为每个点的概率应该是其他点对其概率贡献加和,然后WA看了题解才明白并不是,两个事件的并事件的概率应为P(a | b) = P(a) + P(b) - P(ab)独立事件 P(ab) = P(a) * P(b)举个样例31 2 501 3 500 1 1并不能认为1充电的概率是1的求概率的时候把直接加换成上式就可以了#include<bits/stdc+...原创 2018-04-13 22:35:03 · 215 阅读 · 0 评论