POJ 1201 Intervals(图论-差分约束)
题目大意:
n行,每行a,b,c,表示在区间a,b内要找c个数,问你总共至少要找多少个数?
解题思路:
差分约束系统。
在本题中,如果[a,b]中要找c个元素,那么:s[b]-s[a-1]>=c,我们可以推得:s[a-1] - s[b] <= -c
同时,由于每一个值上最多只能含有一个元素,那么:s[i] - s[i-1]=0 推得:s[i-1] - s[i] <=0
这样:我们有了三个约束不等式:
s...
分类:
其他好文 时间:
2014-06-18 08:05:51
阅读次数:
245
工厂模式分为三大类
简单工厂(SimpleFactory)
工厂方法模式(Factory Method)
抽象工厂模式(Abstract Factory)
动态工厂(Dynamic Factory,属于优化版简单工厂)...
分类:
其他好文 时间:
2014-06-18 07:54:35
阅读次数:
134
LaTeX Subfigure 中间垂直线设定。...
分类:
其他好文 时间:
2014-06-18 07:53:54
阅读次数:
482
Bean的初始化过程已经被Spring完全包装起来了,无法人工干预。
Spring预留了两个回调方法的入口
回调方法:定义出来完成一定的功能,提供给回调者/服务器/上层容器调用的方法,叫做回调方法。
Bean类
public class Bean1 {
public Bean1() {
//System.out.println("bean1...构造方法");
}
...
分类:
编程语言 时间:
2014-06-18 07:04:57
阅读次数:
249
多线程数据同步错误比较难检测,因为通常是与事件的特定发生顺序有关。
一、同步术语
Barrier(屏障)
barrier是多个Thread的集合点:所有的Thread都应该到齐在这个barrier之后才能允许它们继续下去。
Condition variable(条件变量)
实际上不是变量,而是与某个lock有关联的变量。
Event variable(事件变...
分类:
编程语言 时间:
2014-06-18 06:23:12
阅读次数:
356
POJ 3169 Layout (图论-差分约束)
题目大意:
n头奶牛按1到n排好序,md个限制及mt个限制,md行表示奶牛A与奶牛B相差最多D,mt个限制奶牛A与奶牛B相差最少D,问你奶牛1与奶牛n最多相差多少?
解题思路:
限制条件 :
1、相邻奶牛之间,编号大的距离大于编号小的,即 dist[1]-dist[2]<=0,dist[2]-dist[3]<=0,dist[3]-dist[4]<=0。。。。dist[n-1]-dist[n]<=0
2、md个限制 A与奶牛B相差最多D,dist[A]...
分类:
其他好文 时间:
2014-06-18 06:07:39
阅读次数:
209
Problem Description
You are given N positive integers, denoted as x0, x1 ... xN-1. Then give you some intervals [l, r]. For each interval, you need to find a number x to make
as small as possible!
...
分类:
其他好文 时间:
2014-06-18 00:58:54
阅读次数:
276
BACKGROUNDA virtual machine (VM) architecture logically partitions a physical machine, such that the underlying hardware of the machine is time-shared...
分类:
其他好文 时间:
2014-06-17 23:49:03
阅读次数:
350
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2014-06-17 23:38:04
阅读次数:
341
"个记录", "prev"=>"上一页", "next"=>"下一页", "first"=>"首 页", "last"=>"尾 页"); private $listNum=8; /* * $total * $listRows */ public function __constr...
分类:
其他好文 时间:
2014-06-17 23:36:02
阅读次数:
396