上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 43 下一页
摘要: 这道题多了一个检查是否包含所有元素可以设一个cnt表示集合里的数量,再与外面比较#include #include #include using namespace std;#define sf scanf#define pf printf#define debug printf("!\n")#de... 阅读全文
posted @ 2016-01-24 10:39 qlky 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 并查集主要是两个过程,一个是并,一个是查原理是用一个数组p[i]保存每个i的根节点,如果根节点一样则在同一个集合里,所以只有根节点p[i]=i;查:int find(int x){return p[x]==x?x:p[x]=find(p[x]);}并:void Union(int x,int y){... 阅读全文
posted @ 2016-01-24 10:36 qlky 阅读(238) 评论(0) 推荐(0) 编辑
摘要: while(t--)最后结果t=-1#include #include #include #include #include #include #include #include using namespace std;#define MEM(a,b) memset(a,b,sizeof(a))#d... 阅读全文
posted @ 2016-01-24 01:07 qlky 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 这道题提醒我两点:1.break时一定要检查清楚2.字符串直接赋值一定要注意结束符,最好能用strcpy以上是debug的惨痛教训#include #include #include #include #include #include #include #include using namespa... 阅读全文
posted @ 2016-01-24 00:50 qlky 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 这道题有个需要注意的地方,就是范围大小2^16 = 65535,2^32 = 65535(10^4),2^16 =4294967295(10^9),2^64=9223372036854775807(10^18)这道题范围到10^9,3次方就超过了long long,所以可以用除法作为判定条件#inc... 阅读全文
posted @ 2016-01-23 23:24 qlky 阅读(272) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3466http://www.cnblogs.com/andre0506/archive/2012/09/20/2695841.html这道题多了一个限制条件Qi,低于Qi时不能购买。解题思路是看更新量,因为限制条件... 阅读全文
posted @ 2015-12-11 21:40 qlky 阅读(198) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2639http://blog.csdn.net/lulipeng_cpp/article/details/7584981求第K大的思路是把每个d[v]看成是由d[v]和d[v-cost]+weight两个序列组成的... 阅读全文
posted @ 2015-12-11 16:08 qlky 阅读(220) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2184http://blog.csdn.net/liuqiyao_01/article/details/8753686对于负体积问题,可以先定义一个“零点”shift,将dp[shift]设为0,其他都设为-INF。然后负体积从0往maxn+co... 阅读全文
posted @ 2015-12-10 22:17 qlky 阅读(276) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=503以sum/2为背包总量,结果为sum-d*dp[V]#include #inc... 阅读全文
posted @ 2015-12-10 14:11 qlky 阅读(187) 评论(0) 推荐(0) 编辑
摘要: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=565记录路径可以用一个二维数组,记录改变时的量。然后从后往前可以推得所有的值。#include #incl... 阅读全文
posted @ 2015-12-10 10:58 qlky 阅读(223) 评论(0) 推荐(0) 编辑
上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 43 下一页