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

主要是精度和数据范围的问题,首先数据用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. SAS笔记(8) 利用数组重构SAS数据集

    在实际应用中,我们经常会把宽数据(一个患者一条观测)转化为长数据(一个患者多条观测)或者将长数据(一个患者多条观测)转换为宽数据(一个患者一条观测),在R中我们可以利用Reshape2包来实现.在SA ...

  2. Mybatis学习笔记之一——牛刀小试

    1.Mybaits核心对象SqlSession的作用: (1)向SQL语句传入参数: (2)执行SQl语句: (3)获取执行SQL语句的结果: (4)事务的控制: 2.核心配置文件(Configrat ...

  3. spring boot war

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

  4. 平衡树合集(Treap,Splay,替罪羊,FHQ Treap)

    今天翻了翻其他大佬的博客,发现自己有些...颓废... 有必要洗心革面,好好学习 序:正常的BST有可能退化,成为链,大大降低效率,所以有很多方法来保持左右size的平衡,本文将简单介绍Treap,S ...

  5. kindle资源

    化繁为简!Kindle 漫画和电子书 资源汇总 & 用法 刚入Kindle那会,在网上翻看了不少文章,有的讲怎么下载电子书,有的讲怎么看漫画,有的讲怎么设置推送邮箱…… 好吧,我不想在用Kin ...

  6. Hive MetaStore Upgrade

    # cd $HIVE_HOME/scripts/metastore/upgrade/mysql [Dev root @ sd-9c1f-2eac /usr/local/src/apache-hive- ...

  7. SQL Server 查看分区表(partition table)的分区范围(partition range)

    https://www.cnblogs.com/chuncn/archive/2009/02/20/1395165.html SQL Server 2005 的分区表(partition table) ...

  8. 在HEXO主题中添加数学公式支持

    在markdown中书写数学符号的方式参考Latex常用数学符号 Mathjax 安装 npm uninstall hexo-renderer-marked --save npm install he ...

  9. 二维hash

    题目描述 给出一个n * m的矩阵.让你从中发现一个最大的正方形.使得这样子的正方形在矩阵中出现了至少两次.输出最大正方形的边长. 输入描述: 第一行两个整数n, m代表矩阵的长和宽: 接下来n行,每 ...

  10. windows 安装python

    前言: Windows 中直接使用Python真的是心累 安装vs 2017(最好是最新版的, 因为python依赖于一些vs提供的包) 下载最新的python的安装程序 安装完毕之后, 不像Linu ...