Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
以2,3方向为x,y方向的正方向做一下坐标转换,那么A转换为矩形,B转换为两边平行与y轴的平行四边形,C... 然后扩展一下shoelace算法分别计算B类和C类的面积大致这样的 s=sb=sc=0; x1=y1=0; for (i=0; i<=n; i++) { if (i==n) { x2=y2=0; } else { scanf("%d %d", &d, &m); x2=x1+m*ss[d][0]; y2=y1+m*ss[d][1]; } s += (x1*y2); s-= (y1*x2); if (x1!=x2&&y1!=y2) { sc += (y2-y1)*(x1+x2); sb += (x2-x1)*(y1+y2); } x1=x2; y1=y2; } if (s<0) s=-s; s/=2; if (sc<0) sc=-sc; sc/=2; if (sb<0) sb=-sb; sb/=2; sa = s-sb-sc; Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator