分相离,内含,想交三种情况讨论一下。

主要是精度和数据范围的问题,首先数据用long double,能用整型判断就不要用浮点型。

题目中所给的坐标,半径是整型的,出现卡浮点判断的情况还是比较少的。

最后算三角型面积的时候不要用海伦公式,有四个连乘很容易爆数据范围损失精度,即使拆开两两乘也要考虑符号

(取对数也是比较好的办法)。(不知道sqrt和cos,sin的精度如何比较

#include<bits/stdc++.h>
using namespace std; typedef long double ld;
typedef long long ll; ld x[],y[],r[]; inline ld sqr(ld x){ return x*x; }
inline ll sqrl(ll x) { return x*x; }
inline ld fcos(ld a, ld b, ld c)
{
return acosl((a*a+b*b-c*c)/(*a*b));
} inline ld cut(ld ang, ld r)
{
ld s1 = ang*r*r;
ld s2 = sinl(ang)*cosl(ang)*r*r;
return s1 - s2;
} const ld pi = acosl(-); double solve()
{
if(r[] > r[]){
swap(r[],r[]);
swap(x[],x[]);
swap(y[],y[]);
}
ll dx = x[]-x[], dy = y[]-y[];
ll ds = sqrl(dx)+sqrl(dy);
if(ds >= sqrl(r[]+r[])) return ;
ld d = sqrtl(ds);
if(d+r[] <= r[]) return sqr(r[])*pi; ld ang[];
ang[] = fcos(d,r[],r[]);
ang[] = fcos(d,r[],r[]);
/*
WA 28
ld area = ang[1]*sqr(r[1]) + ang[0]*sqr(r[0]);
ld s = (d+r[0]+r[1])/2;
area -= sqrtl(s*(s-d)*(s-r[0])*(s-r[1]))*2; // O(n^4) 拆分会有符号问题 对数也许可行
return area;
*/
return cut(ang[],r[]) + cut(ang[],r[]);
} //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
cin>>x[]>>y[]>>r[]>>x[]>>y[]>>r[];
printf("%.10f\n", solve());
return ;
}

codeforces 600D Area of Two Circles' Intersection的更多相关文章

  1. codeforces D. Area of Two Circles' Intersection 计算几何

    D. Area of Two Circles' Intersection time limit per test 2 seconds memory limit per test 256 megabyt ...

  2. codeforce--600D - Area of Two Circles' Intersection

    题意:求相交圆的面积.借鉴大神代码,精度超高. #include <fstream> #include <iostream> #include <string> # ...

  3. codeforces 630P. Area of a Star

    题目链接 圆上n个点等距离分布, 求构成的星星的面积. 我们可以求三角形OAB的面积, ∠CAE = 1/2 ∠ COE = PI/n, 那么∠CAO = PI/2n, ∠AOB非常好求, 就是PI/ ...

  4. Educational Codeforces Round 2

    600A - Extract Numbers    20171106 字符串处理题,稍微注意点细节就能水过 #include<stdlib.h> #include<stdio.h&g ...

  5. codeforces 几道题目

    BZOJ挂了....明天就要出发去GDKOI了....不能弃疗. 于是在cf水了几道题, 写写详(jian)细(dan)题解, 攒攒RP, 希望GDKOI能好好发挥.......  620E. New ...

  6. Trilateration三边测量定位算法

    转载自Jiaxing / 2014年2月22日 基本原理 Trilateration(三边测量)是一种常用的定位算法: 已知三点位置 (x1, y1), (x2, y2), (x3, y3) 已知未知 ...

  7. Shape comparison language

      形状比较语言, 九交模型 In this topic About shape comparison language Dimensionality Extensions to the CBM SC ...

  8. HDU 1724 Ellipse(数值积分の辛普森公式)

    Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...

  9. A Statistical View of Deep Learning (IV): Recurrent Nets and Dynamical Systems

    A Statistical View of Deep Learning (IV): Recurrent Nets and Dynamical Systems Recurrent neural netw ...

随机推荐

  1. [CentOS7] 常用工具 之 差异备份工具 rdiff-backup

    差异备份: rdiff-backup ==> 用于累积差异备份,加上自己写的shell script,每日备份,效果更佳 先用yum search rdiff-backup看看是否yum源含有r ...

  2. 洛谷P1038 神经网络

    P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...

  3. Linux 常用命令一览

    本篇博文讲述系统内核.Bash解释器的关系与作用,如何正确的执行Linux命令以及常见排错方法. 经验丰富的运维人员可以恰当的组合命令与参数,使Linux字符命令更加的灵活且相对减少消耗系统资源. 强 ...

  4. BUYING FEED

    Problem F: F BUYING FEED Description Farmer John needs to travel to town to pick up K (1 <= K < ...

  5. 兼容IE的login表单巧妙写法

    利用label来写: HTML: <div class="loginwrap"> <label for="phonenumber" class ...

  6. LeetCode初级算法(树篇)

    目录 二叉树的最大深度 验证二叉搜索树 对称二叉树 二叉树的层次遍历 将有序数组转换为二叉搜索树 二叉树的最大深度 二叉树,所以可以考虑用递归来做.由于根节点已经算过了,所以需要加上1:每次返回都是以 ...

  7. 基于svn+ssh:访问svn的部署以及客户端配置

    1.安装ssh sudo apt-get install ssh 2.安装subversion sudo apt-get install subversion 3.为参与项目开发的成员建立用户帐户 s ...

  8. keil编译器

    1 数组比指针效率高. 2 v4.73不能查看局部变量的值:可先将C/C++选项下的优化级别设置成O0,查看完之后修改回去.因默认级别是2级.

  9. UVALive 7500 Boxes and Balls 2015EC final 签到题 二分

    分析题目后,得到要求的是最接近n的一个数,并且这个数字能写成1+2+3+....+x = ans这种形式. 要求的是最大的值. 这题就直接二分去做吧.二分出一个f(mid)<=n的最大值. 最后 ...

  10. Unity MonoBehaviour.Invoke 调用

    使用 Invoke() 方法需要注意 3点: 1 :它应该在 脚本的生命周期里的(Start.Update.OnGUI.FixedUpdate.LateUpdate)中被调用: 2:Invoke(); ...