Circular Area 两圆相交面积(模板)
来源:互联网 发布:开票软件赋码 编辑:程序博客网 时间:2024/05/02 00:56
Circular Area
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5272 Accepted: 2100
Description
Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point.
Input
In the single line of input file there are space-separated real numbers x1 y1 r1 x2 y2 r2. They represent center coordinates and radii of two circles.
Output
The output file must contain single real number - the area.
Sample Input
20.0 30.0 15.0 40.0 30.0 30.0
Sample Output
608.366
套模板求解两圆相交的面积
code:<span style="font-size:18px;">#include<iostream>#include<stdio.h>#include<cmath>#include<cstring>using namespace std;const double pi = 3.141592653;int flag;double solve( double r, double r0, double dis ){ double ang = 2*acos( (r*r + dis*dis - r0*r0) / (2*r*dis ) );//公式 double s2 = 0.5*r*r*sin(ang); double s1 = 0.5*r*r*ang; return s1 - s2;}int main( ){ double x,y,r,x0,y0,r0,dis,ans;//freopen("input.txt","r",stdin);//freopen("output.txt","w",stdout); while( scanf( "%lf%lf%lf%lf%lf%lf",&x,&y,&r,&x0,&y0,&r0 ) != EOF ) { flag=0; dis = sqrt( ( x - x0 )*( x - x0 ) + ( y - y0 )*( y - y0 ) ); if( r < r0 ) swap(r,r0); if(dis>=(r+r0)) printf("0.000\n"); else if(dis+r0<=r) printf("%.3lf\n",pi*r0*r0); else printf("%.3lf\n",solve(r,r0,dis)+solve(r0,r,dis)); } return 0;}</span>
0 0
- Circular Area 两圆相交面积(模板)
- poj 2546 Circular Area (两圆相交面积)
- TOJ 1754.Circular Area(两圆相交求面积)
- poj2546—Circular Area(两圆相交面积)
- TOJ 1754 Circular Area 两圆相交的面积
- POJ 2546 Circular Area 两圆相交面积
- POJ 2546 Circular Area(计算几何 两圆相交面积)
- POJ 2546 Circular Area(两圆相交面积模版题)
- POJ 2546 Circular Area(两个圆相交面积)
- ZOJ.1597 Circular Area【两圆相交面积】 2015/09/23
- Poj.2546 Circular Area【两圆相交面积】 2015/09/23
- POJ 2546 Circular Area【计算几何,计算两圆相交面积】
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
- zoj 1597 Circular Area(求两圆相交的面积)
- zoj 1597 Circular Area (求两园相交面积)
- poj 2546 Circular Area 两圆面积交
- POJ 2546 || Circular Area(两圆面积交
- POJ 2546 Circular Area [相交园面积]【计算几何】
- 李银河:我想让自由和美丽把生命填满
- java和c/c++ 数据类型长度的比较
- Android提高之ListView自适应实现表格
- 各种变量在内存中的分布
- java集合
- Circular Area 两圆相交面积(模板)
- java的高级特性
- linux下查看某一程序具体用到了那些库
- UIKit--UILabel详解
- oracle存储过程例子
- island demo中的combinechildren脚本
- 伪类和为元素
- ImportError: No module named feedparser
- 支付宝充退、充退转账