codeforces 600D. Area of Two Circles' Intersection【几何】
2016-08-17 15:15
513 查看
/* 题意:给你两个圆的圆心和半径,求出两个圆相交的面积 类型:几何 分析:直接套模板0.0 感悟:提交C++在第36个样例蜜汁损失了精度,WA了数次之后,提交了一下G++,过了... 哪位大神能给小弟指点一下。不胜感激。。 */ #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<string> #include<algorithm> #include<iomanip> using namespace std; typedef long double ld; typedef long long ll; ld x[2],y[2],r[2]; 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)/(2*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(-1); ld solve(){ if(r[0] > r[1]){ swap(r[0],r[1]); swap(x[0],x[1]); swap(y[0],y[1]); } ll dx = x[0]-x[1], dy = y[0]-y[1]; ll ds = sqrl(dx)+sqrl(dy); if(ds >= sqrl(r[0]+r[1])) return 0; ld d = sqrtl(ds); if(d+r[0] <= r[1]) return sqr(r[0])*pi; ld ang[2]; ang[0] = fcos(d,r[0],r[1]); ang[1] = fcos(d,r[1],r[0]); return cut(ang[0],r[0]) + cut(ang[1],r[1]); } int main() { cin>>x[0]>>y[0]>>r[0]>>x[1]>>y[1]>>r[1]; cout<<setprecision(8)<<solve()<<endl; return 0; }
相关文章推荐
- Codeforces 682E 计算几何
- Codeforces 659D Bicycle Race【计算几何】
- Codeforces 842B Gleb And Pizza【几何,水】
- Codeforces 801D Volatile Kite 几何
- CodeForces 618 C. Constellation(计算几何)
- codeforces 394E Lightbulb for Minister 简单几何
- codeforces 559A A. Gerald's Hexagon(几何题)
- 「CodeForces - 50C 」Happy Farm 5 (几何)
- Codeforces 659D Bicycle Race【计算几何】
- CodeForces 196 C.Paint Tree(计算几何+递归)
- CodeForces 274C|275E|The Last Hole!|计算几何
- CodeForces - 667B Coat of Anticubism (数学几何规律)
- CodeForces 498A-Crazy Town-简单计算几何
- Codeforces 1C Ancient Berland Circus 计算几何
- codeforces 849B Tell Your World(计算几何)
- codeforces 340B 几何 叉积
- CodeForces 630 O. Arrow(计算几何)
- Codeforces 140 A. New Year Table(计算几何)
- CodeForces 203D Hit Ball 水!计算几何
- Codeforces 1C. Ancient Berland Circus(计算几何:正多边形性质+高精度)