题面

传送门

题解

好神仙……

先给几个定义

平面单连通区域:设\(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. 关于Web应用开发流程的总结

    以下内容为个人工作总结,如果不当,谢谢指出错误. 假设最简单的情况,一个开发人员,开发所有的代码,一个测试人员.一个测试的服务器,一个生产的服务器. 开发人员需要为公司开发一个项目,开发人员首先分析产 ...

  2. SpringBoot的读取properties文件的方式

    转载:https://www.imooc.com/article/18252一.@ConfigurationProperties方式 自定义配置类:PropertiesConfig.java pack ...

  3. Select isnull(,)

    类似于 select isnull(...,1) from table 这样的 isnull函数防止查询结果为空,防止接下来需要这个值时可能造成空指针异常

  4. [C#]RichTextBox实现拖放

    amespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeC ...

  5. C#中隐式运行CMD命令行窗口的方法

    using System; using System.Diagnostics; namespace Business { /// <summary> /// Command 的摘要说明. ...

  6. 20155312 2016-2017-2 《Java程序设计》第八周学习总结

    20155312 2016-2017-2 <Java程序设计>第八周学习总结 课堂内容总结 学习模式 游乐园模式-荒野求生模式 学习方法 以代码为中心->遇到不会的类和方法(参数等) ...

  7. php结合layui实现前台加后台操作

    一:前台加载出前端页面: HTML: lay-data="{width:800,height:400, url:'data.php', page:true, id:'test'} js: l ...

  8. MySQL open_files_limit相关设置

    背景:      数据库链接不上,报错: root@localhost:/var/log/mysql# mysql -uzjy -p -h192.168.1.111 --default-charact ...

  9. IDEA的GUI连接数据库写入SQL语句的问题总结

    一.首先是建立游标的对象statement 插入数据excuteUpdate需要的是一个整型的参数,所以建立的对象要是一个int型的数据类型,才可以执行SQL语句excuteQuery是一个字符类型在 ...

  10. 2019.02.09 codeforces451 E. Devu and Flowers(容斥原理)

    传送门 题意简述:给出n堆花,对于第j堆,有f[j]朵花,每堆花的颜色不同,现在要从中选出s朵,求方案数. 思路: 假设所有花没有上限直接插板法,现在有了上限我们用容斥扣掉多算的 状压一下再容斥:fi ...