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

主要是精度和数据范围的问题,首先数据用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. 【转】vs发布msi程序详解

    源地址:http://wenku.baidu.com/link?url=MV1Mf7IukCZ0cab8AzXQoQ3MAXeUAHGz5b2IuUL4Kw-hCI90ZyBKXwKeQA3t3-SV ...

  2. CF 984C Finite or not? (数论)

    CF 984C Finite or not? (数论) 给定T(T<=1e5)组数据,每组数据给出十进制表示下的整数p,q,b,求问p/q在b进制意义下是否是有限小数. 首先我们先把p/q约分一 ...

  3. 洛谷P3146 [USACO16OPEN]248

    P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...

  4. MCP|ZCM|Investigating Lactococcus lactis MG1363 response to phage p2 infection at the proteome level(研究乳酸乳球菌MG1363在噬菌体p2感染后的蛋白质组水平变化)

    一.概述: 噬菌体是特异性感染并最终杀死其细菌宿主的病毒.他们在所有生态系统中发挥着关键的生态作用.尽管经过了几十年的研究,噬菌体与细菌宿主之间的相互作用仍然知之甚少.本研究使用无标记定量蛋白质组学来 ...

  5. Django路由与视图

    路由层 一.路由匹配规则: 第一个参数是正则表达式,匹配规则按照从上往下一次匹配,匹配到一个之后立即匹配,直接执行对应的视图函数 url(r'login', views.login), 如果按上面的形 ...

  6. VS2017(Visual Studio2017) 搭建QT5开发环境

    VS创建QT工程并添加到GitHub中 大家好! 欢迎打开并阅读本文,这次咱们说说怎么在VS中创建一个QT项目并且放到GitHub中吧 因为GitHub或者码云Gitee都是一个很好的提供代码托管的地 ...

  7. PureComponent

    前言 React15.3中新加了一个 PureComponent 类,PureComponent 也就是纯组件,取代其前身 PureRenderMixin , PureComponent 是优化 Re ...

  8. IDEA的git密码修改

    问题: 如果你办公的电脑是同事用过,在每次提交git的时候都显示是他的名字.想要修改提交git用户名密码. 但是博客idea 修改Git密码和账号方法所示方法无效.且操作系统是win10.(其他操作系 ...

  9. Ubuntu下rsyslog集中收集mysql审计日志

    服务端 1.安装最新版本rsyslog sudo apt-get install software-properties-common python-software-properties sudo ...

  10. 牛客练习赛34-C-little w and Segment Coverage(差分数组)

    链接:https://ac.nowcoder.com/acm/contest/297/C 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...