LightOj 1118 - Incredible Molecules(两圆的交集面积)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1118
给你两个圆的半径和圆心,求交集的面积;

就是简单数学题,但是要注意acos得到的都是小于180度的角,所以这里要注意一下,不要求整个角,求一半的大小;这点让我错的惨不忍睹;
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <math.h> using namespace std; #define met(a, b) memset(a, b, sizeof(a))
#define N 1053
#define INF 0x3f3f3f3f
#define PI 4*atan(1)
const int MOD = ; typedef long long LL; int main()
{
int T, t = ;
scanf("%d", &T);
while(T--)
{
double r1, r2, x1, x2, y1, y2; scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &r1, &x2, &y2, &r2); double d = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); if( d >= r1+r2 )///相离或相切
{
printf("Case %d: %.6f\n", t++, 0.0);
continue;
}
if(d <= fabs(r1-r2))///内含;
{
printf("Case %d: %.6f\n", t++, PI*min(r1, r2)*min(r1, r2));
continue;
} double a = acos((r1*r1+r2*r2-d*d)/(*r1*r2));
double s = sin(a)*r1*r2;///四边形面积
double b = acos((r1*r1+d*d-r2*r2)/(*r1*d));
double s1 = b * r1 * r1;///r1这边的扇形面积;
double c = acos((r2*r2+d*d-r1*r1)/(*r2*d));
double s2 = c * r2 * r2;///r2这边的扇形面积;
double ans = s1 + s2 - s; printf("Case %d: %.7f\n", t++, ans);
}
return ;
}
/*
Input:
5
0 0 1 10 10 1
0 0 10 0 0 5
-862 823 894 -667 402 663
548 518 145 119 828 620
777 499 712 479 314 967 Output:
Case 1: 0.0
Case 2: 78.5398163397
Case 3: 1139058.0639436883
Case 4: 56622.85922574766
Case 5: 1513681.0685423985
*/
LightOj 1118 - Incredible Molecules(两圆的交集面积)的更多相关文章
- LightOJ 1118 - Incredible Molecules (两圆面积交)
1118 - Incredible Molecules PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: ...
- LightOJ 1118--Incredible Molecules(两圆相交)
1118 - Incredible Molecules PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Lim ...
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- 求两圆相交部分面积(C++)
已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...
- codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述
之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...
- 两圆相交求面积 hdu5120
转载 两圆相交分如下集中情况:相离.相切.相交.包含. 设两圆圆心分别是O1和O2,半径分别是r1和r2,设d为两圆心距离.又因为两圆有大有小,我们设较小的圆是O1. 相离相切的面积为零,代码如下: ...
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
- hdu5858 Hard problem(求两圆相交面积)
题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 6354--Everything Has Changed(判断两圆关系+弧长计算)
题目 题意:首先给定一个以原点为圆心,R为半径的圆,之后在给m个圆,这些圆可能会和原来的圆有所交集,计算开始的圆剩余区域的周长,不包括内部周长. 首先判定两圆关系,如果内含,直接加上圆的周长,如果相交 ...
随机推荐
- 使用HTML5监测网站性能
在这个信息爆炸的互联网时代,越来越多的人缺少了等待的耐心,网站性能对于一个网站来说越来越重要.以下为监控到的网站打开时间对跳出率的影响: 当网站打开时间在0-1秒时,跳出率为12% 当网站打开时间在1 ...
- 设置js同源
1)设置 document.domain 成一样的就行了(前提是都是同一个顶级域名) 2)例如,域名1:news.xxx.com ,域名2:member.xxx.com,这时可以设置它们的 docum ...
- javaweb使用cookie存取中文以及读取中文
要想在cookie中存储中文,那么必须使用URLEncoder类里面的encode(String s, String enc)方法进行中文转码,例如: 1 Cookie cookie = new Co ...
- codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)
题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #inc ...
- thinkphp5.0 获取请求信息
如果要获取当前的请求信息,可以使用\think\Request类,除了下文中的 $request = Request::instance(); 也可以使用助手函数 $request = request ...
- Material Design系列第四篇——Defining Shadows and Clipping Views
Defining Shadows and Clipping Views This lesson teaches you to Assign Elevation to Your Views Custom ...
- linux计划任务之crontab
语法: crontab [ -u user ] file crontab [ -u user ] [ -i ] { -e | -l | -r } 说明: crontab命令 ...
- 二、K3 Cloud 开发插件《K3 Cloud 常用数据表整理》
一.数据库查询常用表 --查询数据表select * from ( ),t1.FKERNELXML.query('//TableName')) as 'Item',t1.FKERNELXML,t2.F ...
- Servlet 简单介绍
来源于菜鸟教程http://www.runoob.com/servlet/servlet-intro.html Servlet 简介 Servlet 是什么? Servlet(Server Apple ...
- ssh命令远程登录
1.查看SSH客户端版本 有的时候需要确认一下SSH客户端及其相应的版本号.使用ssh -V命令可以得到版本号.需要注意的是,Linux一般自带的是OpenSSH: 下面的例子即表明该系统正在使用Op ...