dp
文章平均质量分 62
utoppia
这个作者很懒,什么都没留下…
展开
-
sgu 104 Little shop of flowers
题目描述:104. Little shop of flowerstime limit per test: 0.5 sec. memory limit per test: 4096 KBPROBLEMYou want to arrange the window of your flower shop in a most pleasant way. You have原创 2012-10-23 22:57:52 · 488 阅读 · 0 评论 -
Ural 1501
PRO IS HERE dp[x][y][z] 表示s[0......x] ,t[0.......y] 之间0,1的个数之差为z-1(z=0,1,2)记忆化搜索就行了 #include#include#include#include#include#include#include#includeusing namespace std;原创 2013-04-23 23:40:51 · 547 阅读 · 0 评论 -
Ural 1078
PRO IS HERE描述: n段线段,求最长的序列,使得后一条线段包含前一条线段。拓扑排序,然后dp。#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i)=(a);原创 2013-04-24 22:26:52 · 566 阅读 · 0 评论 -
Ural 1346
PRO IS HERE将序列分成最少的段,每段都是非递减,或者非递增的。dp: dp[i][0] 表示到i点是非递增的划分数 dp[i][1] 表示到i点是非递减的划分数#include#include#include#include#include#include#include#includeusing namespace原创 2013-04-24 23:23:29 · 642 阅读 · 0 评论 -
Ural 1287
PRO IS HEREn*n矩阵,统计连续的横,竖,斜的'S' 和 's' 的个数的最大值,输出较大的那个。暴力dp#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i)=(a)原创 2013-04-24 23:57:32 · 585 阅读 · 0 评论 -
Ural 1427
PRO IS HERE描述:将一段文本分成最少的几段,全是由空格和字母组成的最长可拥有m个字符,否则最多含n个字符。求最少的段数。我们假设第一种方案是只存储空格和字母,第二种方案为其他。DP : dp[i][0] 表示到i这个点且这个点用的是第一种方案的最少的切段。 dp[i][1] 表示。。。。。。。。。。。。第二种方案。。。。。原创 2013-04-25 00:36:40 · 606 阅读 · 0 评论 -
Ural 1513
PRO IS HERE题目大意就是将长度为n的全为1的数组,将其中某些1变为0,使得没有k个以上连续的1.dp[i][0] 表示第i位是0满足条件的个数dp[i][1] 表示第i位时1满足条件的个数dp[i][1] = dp[i-1][0] + dp[i-1][1]dp[i][0] = dp[i-k][1] + dp[i-k+1][1] +.... + dp[i原创 2013-04-28 10:51:56 · 674 阅读 · 0 评论 -
Ural 1495
PRO IS HERE题目大意就是问是否存在长度小于31的仅有1,2组成的数,整除n。若有,输出最小的。dp[i] 表示模为i的最小的数。考虑(1#include#include#include#include#include#include#include#include#includeusing namespace std;#define原创 2013-04-28 14:27:59 · 706 阅读 · 0 评论 -
Ural 1410
PRO IS HERE恶心的输入,注意input可能不止一行,所以。。。。我就是这么悲剧。#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i原创 2013-04-28 16:09:38 · 638 阅读 · 0 评论 -
Ural 1029
PRO IS HERE双向dp。#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)原创 2013-04-22 11:12:00 · 530 阅读 · 0 评论 -
Ural 1658 Sum of Digits
PRO IS HERE0我用队列直接枚举(s1,s2) 是否可行。dp[s1][s2] 表示达到(s1,s2) 加的数,就是:s1 = S1 - dp[s1][s2] ,s2 = S2 - dp[s1][s2]^2No solution 打成 NO solution WA 了n次。。。#include#include#include#inclu原创 2013-04-22 00:26:00 · 572 阅读 · 0 评论 -
Ural 1326
PRO IS HERE集合的动态规划。。。code:#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)+原创 2013-05-21 11:15:47 · 557 阅读 · 0 评论 -
Ural 1577 E-mail
PRO IS HEREA Easy Dp Problem.Code:#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i)=(a);(i)<=原创 2013-05-21 11:50:23 · 664 阅读 · 0 评论 -
Ural 1172 Ship Routes
PRO IS HERE大数什么的果断python 无压力.....Code:dp=[]def check(a,cur): for i in xrange(0,3) : if i!=cur: if a[i]!=0: return 0 return 1def dfs(a,cur): if dp[cur][a[0]][a[1]][a[2]]!=-原创 2013-05-21 16:40:07 · 1243 阅读 · 0 评论 -
ural 1039
树型dp.#include#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)#原创 2013-04-22 23:19:24 · 653 阅读 · 0 评论 -
ural 1244
PRO IS HERE简单的背包问题,输出yy一下就可以了。#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(i原创 2013-04-22 12:01:12 · 630 阅读 · 0 评论 -
sgu 131 Hardwood floor
题目描述:131. Hardwood floortime limit per test: 0.5 sec. memory limit per test: 4096 KBThe banquet hall of Computer Scientists' Palace has a rectangular form of the size M x N (11) rect原创 2012-11-01 18:48:23 · 922 阅读 · 1 评论 -
sgu 149 Computer Network
题目描述:149. Computer Networktime limit per test: 0.5 sec.memory limit per test: 4096 KBinput: standard inputoutput: standard outputA school bought the first computer some time原创 2012-11-04 15:34:50 · 479 阅读 · 0 评论 -
sgu 143 Long Live the Queen
题目描述:143. Long Live the Queen time limit per test: 0.5 sec. memory limit per test: 4096 KBThe Queen of Bytelandis very loved by her people. In order to show her their love, the Bytelan原创 2012-11-04 10:47:31 · 580 阅读 · 0 评论 -
sgu 116 Index of super-prime
题目描述:116. Index of super-primetime limit per test: 0.5 sec. memory limit per test: 4096 KBLet P1, P2, … ,PN, … be a sequence of prime numbers. Super-prime number is such a prime number原创 2012-10-26 11:38:49 · 577 阅读 · 0 评论 -
sgu 168 Matrix
168. Matrixtime limit per test: 1 sec.memory limit per test: 16000 KBinput: standardoutput: standardYou are given N*M matrix A. You are to find such matrix B, that B[i,j]=min{ A[x,原创 2012-11-06 00:19:01 · 456 阅读 · 0 评论 -
sgu 199 Beautiful People
199. Beautiful Peopletime limit per test: 0.5 sec.memory limit per test: 65536 KBinput: standardoutput: standardThe most prestigious sports club in one city has exactly N members.原创 2012-11-08 12:31:05 · 840 阅读 · 0 评论 -
dp (不断更新)
Ignatius and the Princess III :简单的dp,dp[i][j]表示和是i最小的加数是j原创 2013-03-14 15:43:09 · 554 阅读 · 0 评论 -
Ural 1635
我是题目#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)原创 2013-04-10 23:47:23 · 622 阅读 · 0 评论 -
Ural 1117
YOU CAN SEE THE PRO HERE#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(原创 2013-04-11 01:01:44 · 640 阅读 · 0 评论 -
Ural 1635
#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)#define nMax 10原创 2013-04-10 23:05:37 · 671 阅读 · 0 评论 -
Ural 1741
#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)+原创 2013-04-11 02:13:26 · 548 阅读 · 0 评论 -
ural 1036
PRO IS HERE一道比较简单的dp,比较恶心的是大数。。。直接python AC掉,好开心,纪念一下n,s=raw_input().split()n=int(n)s=int(s)if s%2 == 1: print 0else: s /= 2 b=[] b.append([]) a=[] for i in xrange(0,10): a原创 2013-04-11 22:55:37 · 786 阅读 · 0 评论 -
Uarl 1303
PRO IS HERE其实只是简单的贪心即可,按(x,y) 排序,然后尽量取y大的。。。#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(原创 2013-04-11 20:39:47 · 604 阅读 · 0 评论 -
Ural 1018 树dp
PRO IS HERE树dp:#include#include#include#include#include#include#include#includeusing namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)<原创 2013-04-11 21:26:31 · 612 阅读 · 0 评论 -
POJ1678 I Love this Game!
POJ1678 I Love this Game!博弈DP,蛮有意思的一道题目。。。#include#include#include#include#include#include#include#include#includeusing namespace std;#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);原创 2013-08-16 23:30:28 · 650 阅读 · 0 评论