随笔分类 - 简单dp
1
摘要:solution : 就按题解敲了一遍,好久没写这种dp1#include2#include3#include4#include5#include6#include7usingnamespacestd;8typedeflonglongLL;9constintMAX=1e3+10;10constint...
阅读全文
摘要:http://ygdtc.sinaapp.com/?p=219
阅读全文
摘要:dp :#include#include#includeusingnamespacestd;constintMAX=51;doubledp[MAX*MAX][MAX][MAX];intmain(){intcas;intn,m;scanf("%d",&cas);while(cas--){scanf("...
阅读全文
摘要:题意: 给出最多5个序列,问这几个序列的最长公共子序列的长度是多少。solution : 脑抽级别我是,第一个序列每个数字位置固定,这样只要维护一个k-1维的偏序集就好了。然后在保证每个位置合法的情况下走一遍最长上升子序列就好了。1#include2usingnamespacestd;3consti...
阅读全文
摘要:1#include2#include3#include4#include5#include6usingnamespacestd;7constintinf=0x3f3f3f3f;8constintMAX=200+10;9doubleGPA[10],dp1[20][30000],dp2[20][3000...
阅读全文
摘要:Another OCD PatientProblem DescriptionXiaoji is an OCD (obsessive-compulsive disorder) patient. This morning, his children played with plasticene. The...
阅读全文
摘要:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4441题意:有n个靶子,每个靶子有3个val,需要满足3钟情况分别得到他们的val。问最大的...
阅读全文
摘要:C. Petya and SpidersLittle Petya loves training spiders. Petya has a boardn × min size. Each cell of the board initially has a spider sitting on it. A...
阅读全文
摘要:E. Pashmak and GraphPashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem....
阅读全文
摘要:D. Little Pony and Harmony Chesttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPrincess Twiligh...
阅读全文
摘要:2048Problem DescriptionTeacher Mai is addicted to game 2048. But finally he finds it's too hard to get 2048. So he wants to change the rule:You are gi...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3664题意:给出数字n,问n的所有的排列中满足Ai>i 数字恰好为 k的排列的个数。sl : dpdp【n】【k】 = dp【n-1】【k】*(k+1) + dp【n-1】【k-1】*(n-1-k+1);为什么? ...
阅读全文
摘要:Stupid Tower DefenseProblem DescriptionFSF is addicted to a stupid tower defense game. The goal of tower defense games is to try to stop enemies from ...
阅读全文
摘要:D. A Lot of Gamestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew, Fedor and Alex are inven...
阅读全文
摘要:The Romantic HerProblem DescriptionThere is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy thi...
阅读全文
摘要:Iahub accidentally discovered a secret lab. He found there n devices ordered in a line, numbered from 1 to n from left to right. Each device i (1 ≤ i ...
阅读全文
摘要:D. Mashmokh and ACMMashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one ...
阅读全文
摘要:D. Counting Rectangles is Funtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is ann × mrectangular grid, each cell of the grid contains a single integer: zero or one. Let's call the cell on thei-th row and thej-th column as(i, j).L
阅读全文
摘要:简单的矩阵上的dp从左上角扫到右下角,dp[i][j][0] 代表在i,j处选A ,dp[i][j][1] 代表在i,j处选B.dp[i][j][0]=max(dp[i-1][j][1],dp[i-1][j][0])+suma[i][j]-suma[i][0];dp[i][j][1]=max(dp[i][j-1][1],dp[i][j-1][0])+sumb[i][j]-sumb[0][j];View Code
阅读全文
摘要://从上到下从左向右扫一遍即可,类似一维硬币拼凑1//二维0-1背包2//dp[i+k][j+p]+=dp[i][j];(计数dp)3//中等偏下题目4#include5#include6#include7#defineMAX10008#definemod100009usingnamespacestd;10intdp[MAX][MAX];11intmap[MAX][MAX];12intmain()13{14intcas,m,n;15scanf("%d",&cas);16while(cas--)17{18scanf("%d%d",&n,&a
阅读全文
1