摘要: pick定理:一个计算点阵中顶点在格点上的多边形面积公式:S=a+b÷2-1,其中a表示多边形内部的点数,b表示多边形边界上的点数,s表示多边形的面积。思路:http://blog.csdn.net/magicnumber/article/details/6192242#include #include #include #include #define LL long long intusing namespace std;const int MAXN = 1000100;const LL dx[] = { 0, -1, -1, -1, 0, 1, 1, 1 };const LL 阅读全文
posted @ 2013-08-13 10:57 冰鸮 阅读(244) 评论(0) 推荐(0)
摘要: 裸线段树,不过不是很好写,需要注意的地方挺多的。用sum[0],sum[1],sum[2]分别记录一次方和,平方和和立方和,更新的时候推一个增量公式:一次方:sum[0]+=(r - l + 1)*c;二次方: ∵(a+b)2=a2+2*a*b+b2; ∴ (xl+c)2 + (xl+1+c)2+……+(xr+c)2=xl2+xl+12+……+xr2+2*c*(xl+xl+1+……+xr)+(r-l+1)*c2; ∴ sum[1] = sum[1]+2*c*sum[0]+(r-l+1)*c2;(注:此处的sum[0]是未更新前的sum[0])三次方: ∵(... 阅读全文
posted @ 2013-08-13 09:48 冰鸮 阅读(511) 评论(0) 推荐(0)