Problem Description
Edward is a worker for Aluminum Cyclic Machinery. His work is operating mechanical arms to cut out designed models. Here is a brief introduction of his work.
Assume the operating plane as a two-dimensional coordinate system. At first, there is a disc with center coordinates (0,0) and radius R. Then, m mechanical arms will cut and erase everything within its area of influence simultaneously, the i-th area of which is a circle with center coordinates (xi,yi) and radius ri (i=1,2,⋯,m). In order to obtain considerable models, it is guaranteed that every two cutting areas have no intersection and no cutting area contains the whole disc.
Your task is to determine the perimeter of the remaining area of the disc excluding internal perimeter.
Here is an illustration of the sample, in which the red curve is counted but the green curve is not.
 
Input
The first line contains one integer T, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers m and R.
The i-th line of the following m lines contains three integers xi,yi and ri, indicating a cutting area.
1≤T≤1000, 1≤m≤100, −1000≤xi,yi≤1000, 1≤R,ri≤1000 (i=1,2,⋯,m).
 
Output
For each test case, print the perimeter of the remaining area in one line. Your answer is considered correct if its absolute or relative error does not exceed 10−6.
Formally, let your answer be a and the jury's answer be b. Your answer is considered correct if |a−b|max(1,|b|)≤10−6.
 
Sample Input
1
4 10
6 3 5
10 -4 3
-2 -4 4
0 9 1
 
Sample Output
81.62198908430238475376
 
Source
 
Recommend
chendu   |   We have carefully selected several similar problems for you:  6361 6360 6359 6358 6357 
 
 
 
 #include <bits/stdc++.h>
using namespace std;
#define N 120
#define pi acos(-1.0)
struct point{
double x,y;
};
struct circle{
point po;
double r;
}cir[N];
double dist (point a,point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int t,m;
double R;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%lf",&m,&R);
circle a;
a.po.x=;a.po.y=;
a.r=R;
for(int i=;i<m;i++)
{
scanf("%lf%lf%lf",&cir[i].po.x,&cir[i].po.y,&cir[i].r);
}
double ans=*pi*R;
for(int i=;i<m;i++)
{
double dis=dist(a.po,cir[i].po);
if(dis-cir[i].r<a.r&&dis+cir[i].r>=a.r){
double d1=*acos((dis*dis+a.r*a.r-cir[i].r*cir[i].r)/(*dis*a.r));
double d2=*acos((dis*dis+cir[i].r*cir[i].r-a.r*a.r)/(*dis*cir[i].r));
double l1=d1*a.r;
double l2=d2*cir[i].r;
ans-=l1;
ans+=l2;
}
}
printf("%.10f\n",ans);
} return ;
}
/*
//判段两个圆的位置关系:
相离 : dis(a,b)>a.r+b.r
外切 : dis(a.b)==a.r+b.r
相交 : dis(a,b)-min(a.r,b.r)<max(a.r,b.r)&&dis(a,b)+min(a.r,b.r)>max(a.r,b.r)
内切 : dis(a,b)+min(a.r,b.r)==max(a.r,b.r)
内含 : dis(a,b)+min(a,r)<max(a.r,b.r)
*/
 

hdu 6354的更多相关文章

  1. HDU 6354.Everything Has Changed-简单的计算几何、相交相切圆弧的周长 (2018 Multi-University Training Contest 5 1005)

    6354.Everything Has Changed 就是计算圆弧的周长,总周长=大圆周长+相交(相切)部分的小圆的弧长-覆盖掉的大圆的弧长. 相交部分小圆的弧长直接求出来对应的角就可以,余弦公式, ...

  2. HDU 6354 Everything Has Changed(余弦定理)多校题解

    题意:源点处有个圆,然后给你m个圆(保证互不相交.内含),如果源点圆和这些原相交了,就剪掉相交的部分,问你最后周长(最外面那部分的长度). 思路:分类讨论,只有内切和相交会变化周长,然后乱搞就行了.题 ...

  3. HDU 6351暴力枚举 6354计算几何

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. (转) RHEL7 忘记密码修改root密码

    博客链接:http://blog.csdn.net/derkampf/article/details/54346516 RHEL7进入单用户方式和重置密码方式发生了较大变化,GRUB由b引导变成了ct ...

  2. Spark Mllib里如何建立密集向量和稀疏向量(图文详解)

    不多说,直接上干货! 具体,见 Spark Mllib机器学习实战的第4章 Mllib基本数据类型和Mllib数理统计

  3. 《javascript设计模式》笔记之第十二章:装饰者模式

    一.装饰者模式的作用 为函数或者对象的方法添加一些行为.     二.装饰者模式的原理 装饰者模式不是直接修改对象,而是以要修改的对象为基础,新建一个对象.不过这个新建的对象看起来就像在原对象的基础上 ...

  4. arcgis python 保存当前窗口图形为jpg

    1,第一步打开arcgis 将图形加载进去 第二步,将要保存的图形调到合适的比例尺,然后点击下面按钮 第三步,将写好的python 语句放到里面去: import arcpy mxd = arcpy. ...

  5. css3相关样式

    1.渐变 1.1 线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向 background: linear-gradient(direction, color-stop1 ...

  6. File类--System.out.print(Object obj)的理解

    一.File 类(java.io) 概述:Java中使用File类来表示文件或者文件夹对象!     抽象路径名:描述文件或文件夹时,使用的路径符号,就是一个对象的字符串表示形式,如"c:\ ...

  7. 【extjs6学习笔记】1.3 初始:根据模板创建项目

    使用sencha创建应用 命令说明:sencha -sdk /path/to/sdk generate app -s /your/templates/path/ MyApp /path/to/myap ...

  8. WinForm 窗体

    Winform是.NET开发中对windows Form的一种称谓,form是窗体的意思,winform 称之为windows form. 一般中我们使用的东西分为 客户端.网页.APP 三大类. w ...

  9. Android商城开发系列(七)—— 使用RecyclerView展示首页数据

    前面我们讲到了使用OkHttp请求网络和FastJson解析数据了,接下来我们就开始把获取到的数据通过数据适配器展示在页面上了.Adapter是用来帮助填充数据的中间桥梁,简单点说就是:将各种数据以合 ...

  10. acdream 小晴天老师系列——我有一个数列! (ST算法)

    小晴天老师系列——我有一个数列! Time Limit: 20000/10000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)S ...