题面

传送门

题解

好神仙……

先给几个定义

平面单连通区域:设\(D\)是平面内一区域,若属于\(D\)内任一简单闭曲线的内部都属于\(D\),则称\(D\)为单连通区域。通俗地说,单连通区域是没有“洞”的区域。

正方向:当\(xOy\)平面上的曲线起点与终点重合时,则称曲线为闭曲线。设平面的闭曲线L围成平面区域\(D\),并规定当一个人沿闭曲线\(L\)环行时,区域\(D\)总是位于此人的左侧,称此人行走方向为曲线L关于区域\(D\)的正方向,反之为负方向。

格林公式:设\(D\)是一个平面单连通区域,\(L\)是它取正向的轮廓线(分段光滑),\(P,Q\)在\(D\)上具有一阶连续偏导数,则有格林公式

\[\int\int\limits_D\left({\partial Q\over \partial x}-{\partial P\over \partial y}\right)\mathrm dx\mathrm dy=\oint\limits_LP\mathrm dx+Q\mathrm dy
\]

关于那个\(\oint\)就是一个有方向的\(\int\),直接当成\(\int\)看就好了

回到本题,我们令\(Q=x,P=-y\),我们要求的东西就是

\[\int\int\limits_D1\mathrm dx\mathrm dy={1\over 2}\oint\limits_L-y\mathrm dx+x\mathrm dy
\]

这样转化之后,我们就可以把圆的面积转化成跟轮廓线有关的计算了

因为圆弧上\(x,y\)很麻烦,我们用角度来表示它

\[\begin{aligned}
\int\limits_L-y\mathrm dx+x\mathrm dy
&=\int\limits_L-(y_0+r\sin t)\mathrm d(x_0+r\cos t)+(x_0+r\cos t)\mathrm d(y_0+r\sin t)\\
&=\int\limits_L(y_0+r\sin t)(r\sin t)+(x_0+r\cos t)(r\cos t)\\
&=r\int\limits_L(y_0+r\sin t)\sin t+(x_0+r\cos t)\cos t\\
&=r\int\limits_L r+y_0\sin t+x_0\cos t\\
&=r^2t+x_0\sin t-y_0\cos t
\end{aligned}
\]

然后把圆弧的轮廓线搞出来做曲线积分,求和就可以了

顺便这样例太凉心了

//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1005;const double Pi=acos(-1.0);
struct Point{
int x,y;
inline Point(){}
inline Point(R int xx,R int yy):x(xx),y(yy){}
inline Point operator +(const Point &b)const{return Point(x+b.x,y+b.y);}
inline Point operator -(const Point &b)const{return Point(x-b.x,y-b.y);}
inline bool operator <(const Point &b)const{return x<b.x||(x==b.x&&y<b.y);}
inline bool operator ==(const Point &b)const{return x==b.x&&y==b.y;}
inline double norm(){return sqrt(x*x+y*y);}
};
struct Cir{
Point p;int r;
inline bool operator <(const Cir &b)const{return p<b.p||p==b.p&&r<b.r;}
inline bool operator ==(const Cir &b)const{return p==b.p&&r==b.r;}
inline double oint(R double t1,R double t2){
return r*(r*(t2-t1)+p.x*(sin(t2)-sin(t1))-p.y*(cos(t2)-cos(t1)));
}
}c[N];
pair<double,int>st[N<<1];int n;double res;
double calc(int id){
int top=0,cnt=0;
fp(i,1,n)if(i!=id){
double dis=(c[i].p-c[id].p).norm();
if(c[id].r+dis<=c[i].r)return 0;
if(c[i].r+dis<=c[id].r||c[i].r+c[id].r<=dis)continue;
double del=acos((c[id].r*c[id].r+dis*dis-c[i].r*c[i].r)/(2*c[id].r*dis));
double ang=atan2(c[i].p.y-c[id].p.y,c[i].p.x-c[id].p.x);
double l=ang-del,r=ang+del;
if(l<-Pi)l+=2*Pi;if(r>=Pi)r-=2*Pi;
if(l>r)++cnt;
st[++top]=make_pair(l,1),st[++top]=make_pair(r,-1);
}
st[0]=make_pair(-Pi,0),st[++top]=make_pair(Pi,0);
sort(st+1,st+1+top);
double res=0;
for(R int i=1;i<=top;cnt+=st[i++].second)
if(!cnt)res+=c[id].oint(st[i-1].first,st[i].first);
return res;
}
int main(){
// freopen("testdata.in","r",stdin);
scanf("%d",&n);
fp(i,1,n)scanf("%d%d%d",&c[i].p.x,&c[i].p.y,&c[i].r);
sort(c+1,c+1+n),n=unique(c+1,c+1+n)-c-1;
fp(i,1,n)res+=calc(i);
printf("%.3lf\n",res*0.5);
return 0;
}

BZOJ2178: 圆的面积并(格林公式)的更多相关文章

  1. [SPOJ-CIRU]The area of the union of circles/[BZOJ2178]圆的面积并

    [SPOJ-CIRU]The area of the union of circles/[BZOJ2178]圆的面积并 题目大意: 求\(n(n\le1000)\)个圆的面积并. 思路: 对于一个\( ...

  2. BZOJ2178 圆的面积并 计算几何 辛普森积分

    原文链接https://www.cnblogs.com/zhouzhendong/p/BZOJ2178.html 题目传送门 - BZOJ2178 题意 给出 $n(n\leq 1000)$ 个圆,求 ...

  3. bzoj2178: 圆的面积并

    Description 给出N个圆,求其面积并 Input 先给一个数字N ,N< = 1000 接下来是N行是圆的圆心,半径,其绝对值均为小于1000的整数 Output 面积并,保留三位小数 ...

  4. BZOJ2178 圆的面积并(simpson积分)

    板子题.可以转一下坐标防止被卡.精度和常数实在难以平衡. #include<iostream> #include<cstdio> #include<cmath> # ...

  5. 【BZOJ2178】圆的面积并(辛普森积分)

    [BZOJ2178]圆的面积并(辛普森积分) 题面 BZOJ 权限题 题解 把\(f(x)\)设为\(x\)和所有圆交的线段的并的和. 然后直接上自适应辛普森积分. 我精度死活一个点过不去,不要在意我 ...

  6. 【题解】CIRU - The area of the union of circles [SP8073] \ 圆的面积并 [Bzoj2178]

    [题解]CIRU - The area of the union of circles [SP8073] \ 圆的面积并 [Bzoj2178] 传送门: \(\text{CIRU - The area ...

  7. JAVA求圆的面积

    import java.text.DecimalFormat;import java.util.Scanner; public class TheAreaOfCircle { public stati ...

  8. c语言求平面上2个坐标点的直线距离、求俩坐标直线距离作为半径的圆的面积、递归、菲波那次数列、explode

    #include <stdio.h> #include <math.h> #include <string.h> char explode( char * str ...

  9. 【BZOJ】2178: 圆的面积并

    http://www.lydsy.com/JudgeOnline/problem.php?id=2178 题意:给出n<=1000个圆,求这些圆的面积并 #include <cstdio& ...

随机推荐

  1. Python module : simuPOP

    conda config --add channels conda-forge conda install simupop simuPOP is a general-purpose individua ...

  2. 弹出DIV锁定代码

    <html>  <head>  <meta http-equiv="Content-Type" content="text/html; ch ...

  3. 非接触IC卡中typeA卡和typeB卡的区别--总结,二者的调制方式和编码方式不同

    非接触IC卡中typeA卡和typeB卡的区别--总结,二者的调制方式和编码方式不同 1.非接触式IC卡的国际规范ISO/IEC14443的由来? 在非接触式IC卡的发展过程中,这些问题逐渐被解决并形 ...

  4. python console 设立快捷键 学习源码 用到英语

    arbitrary---随意 iterable----迭代 invalid syntax   -----无效的语法 subscriptable   ----可索引访问的

  5. mysql之零碎知识

    一 视图 什么是视图:视图就是一张虚拟表.方便查看. 创建视图:create view 起名 as sql语句 #两张有关系的表 mysql> select * from course; +-- ...

  6. 转--O2O刷单“黑市”折射下的泡沫#神作#

    “XX打车和XX用车这样的公司,太不真诚.从前补贴的是现金,现在补贴的都是各种券,还有各种使用上的规则,为什么要设置这么多的限制?反正都要花一样的钱,为什么不能痛快点?让用户体验好一点?” 说这个话的 ...

  7. vue-cli项目中使用rem

    1.安装px2rem插件 npm install px2rem-loader lib-flexible --save 2.在main.js中引入lib-flexible import 'lib-fle ...

  8. SVD(6.5.1定理证明观察3)

  9. #pragma warning(disable 4786)

    #pragma warning(disable 4786) 此warning产生的原因是因为标识符过长,超过了最大限定255个字符类名超过了255个字符,使用时就会报4786的waring. 在使用S ...

  10. UVa 10828 Back to Kernighan-Ritchie (数学期望 + 高斯消元)

    题意:给定一个 n 个结点的有向图,然后从 1 结点出发,从每个结点向每个后继结点的概率是相同的,当走到一个没有后继结点后,那么程序终止,然后问你经过每个结点的期望是次数是多少. 析:假设 i 结点的 ...