摘要: 1~N连续的白格子,给出若干操作,分为两种,在[1,ai]里选择xi个白格子染成黑色,以及在[ai,n]里选择xi个白格子染成黑色。问把最多的格子染成黑色至少需要多少次操作。 先只考虑第一种操作,显然优先把最左边的填满,对于第二种操作,优先把最右边的填满。这就转化成了背包模型,做完两遍后合并背包即可。 1 #include <string.h> 2 #include <stdio.h> 3 #include <algorithm> 4 #define INF 0x3f3f3f3f 5 #define MAXN 1005 6 using namespace s 阅读全文
posted @ 2012-10-03 08:56 Burn_E 阅读(232) 评论(0) 推荐(0)
摘要: 统计三角形内点的个数。 如下图所示,P(ABC)=|P(AB)+P(BC)-P(AC)|。P(AB)代表线段AB上方的点的个数 1 #include <string.h> 2 #include <stdio.h> 3 #include <algorithm> 4 #define MAXN 105 5 typedef long long LL; 6 struct pnt{ 7 LL x, y; 8 bool operator < (const pnt &p) const {return x < p.x;} 9 }pn[MAXN], pm[M 阅读全文
posted @ 2012-10-03 08:43 Burn_E 阅读(169) 评论(0) 推荐(0)