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)(0,0) and radius RR. Then, mm mechanical arms will cut and erase everything within its area of influence simultaneously, the ii-th area of which is a circle with center coordinates (xi,yi)(xi,yi) and radius riri (i=1,2,⋯,m)(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 TT, indicating the number of test cases. 
The following lines describe all the test cases. For each test case: 
The first line contains two integers mm and RR. 
The ii-th line of the following mm lines contains three integers xi,yixi,yi and riri, indicating a cutting area. 
1≤T≤10001≤T≤1000, 1≤m≤1001≤m≤100, −1000≤xi,yi≤1000−1000≤xi,yi≤1000, 1≤R,ri≤10001≤R,ri≤1000 (i=1,2,⋯,m)(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−610−6.
Formally, let your answer be aa and the jury's answer be bb. Your answer is considered correct if |a−b|max(1,|b|)≤10−6|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

 1 #include <iostream>
2 #include <stdio.h>
3 #include <algorithm>
4 #include <cmath>
5 #include <math.h>
6 #include <cstring>
7 #include <string>
8 #include <queue>
9 #include <deque>
10 #include <stack>
11 #include <stdlib.h>
12 #include <list>
13 #include <map>
14 #include <utility>
15 #include <time.h>
16 #include <set>
17 #include <bitset>
18 #include <vector>
19 #define ms(a,b) memset(a,b,sizeof(a))
20 #define ll long long
21
22 using namespace std;
23
24 const int maxn = 100+10;
25 const int INF = 0x3f3f3f3f;
26
27 double dis(double x1,double y1){
28 return sqrt(x1 * x1 + y1 * y1);
29 }
30 int main(){
31 int t;
32 double pi = acos(-1.0);
33 char n[12];
34 cin >> t;
35 while(t--){
36 double ans;
37 double R;
38 int m;
39 cin >> m;
40 scanf ("%lf",&R);
41 ans = 2 * R * pi;
42 while(m--)
43 {
44 double x,y,r;
45 scanf("%lf%lf%lf",&x,&y,&r);
46 double dist = dis(x,y);
47 if(dist + r == R)
48 {
49 ans += 2 * r * pi;
50 }
51 else if(dist >= r + R || dist + r < R)
52 {
53 continue;
54 }
55 else
56 {
57 double del = acos((R * R + dist * dist - r * r) / (2 * dist * R));
58 double si = acos((r * r + dist * dist - R * R) / (2 * dist * r));
59 ans = ans - del * R * 2 + si * r * 2;
60 }
61 }
62 printf("%lf\n",ans);
63 }
64 return 0;
65 }

E - Everything Has Changed HDU - 6354的更多相关文章

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

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

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

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

  3. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

  4. hdu 6354

    Problem Description Edward is a worker for Aluminum Cyclic Machinery. His work is operating mechanic ...

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

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

  6. 6354 Everything Has Changed

    Edward is a worker for Aluminum Cyclic Machinery. His work is operating mechanical arms to cut out d ...

  7. HDU 6354--Everything Has Changed(判断两圆关系+弧长计算)

    题目 题意:首先给定一个以原点为圆心,R为半径的圆,之后在给m个圆,这些圆可能会和原来的圆有所交集,计算开始的圆剩余区域的周长,不包括内部周长. 首先判定两圆关系,如果内含,直接加上圆的周长,如果相交 ...

  8. hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  9. HDU 1890 区间反转

    http://acm.hdu.edu.cn/showproblem.php?pid=1890 Robotic Sort Problem Description Somewhere deep in th ...

  10. hdu 5412 CRB and Queries

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5412 CRB and Queries Description There are $N$ boys i ...

随机推荐

  1. AI到底给我们带来什么?

    AI 如火如荼,尤其是最近半年,发展的速度超出想象.DeepSeek的出现,对于整个世界AI 界带来深渊影响. AI是当前"技术找技术"的极致产物, 它大幅提升了流程效率,但没有带 ...

  2. 为何PostgreSQL没有聚集索引?解读两大数据库的设计差异

    为何PostgreSQL没有聚集索引?解读两大数据库的设计差异 前言 高效的数据检索是数据库管理的基石, PostgreSQL和SQL Server都能提供强大的数据访问方法以支持各种工作负载方面表现 ...

  3. python实现字符输入实时读取

    原理:通过opencv中的waitKey来实现 示例代码: def key_control(): while 1: cv2.imshow('tmp', np.zeros(shape=(100, 100 ...

  4. 「Note」数论方向 - 数论基础

    0. 前置知识 0.1. 费马小定理 \[a ^{p-1}\equiv1\pmod p(p\in\mathbb P,a\perp p) \] 由此可以推出模意义下乘法逆元: \[a ^{-1}\equ ...

  5. 设置java程序的守护进程

    1.在服务器执行:crontab -e 命令 2.在出现的界面编写cron表达式  3.编写guard_java_extbork.sh脚本 #!/bin/bash source /etc/profil ...

  6. Error creating bean with name 'xxx' defined in file异常处理

    SpringBoot整合mybatis 今天在使用mybatis generator时遇到一个坑,出现以下错误 Error creating bean with name 'authorizeCont ...

  7. SQL Server 链接服务器"XXXXXXX"的 OLE DB 访问接口 "SQLNCLI11" 返回了消息 "没有活动事务。"。

    一.确保互联双方服务器MS DTC服务已启动并正确配置 打开"服务"管理控制台(services.msc) 找到"Distributed Transaction Coor ...

  8. [原创]《C#高级GDI+实战:从零开发一个流程图》第04章:来个圆形,连线它!

    一.前言 上一节我们实现了在矩形与矩形之间添加连线,光是矩形太单调了,某些问题也暴露不出来,我们本节就来看一下,如何添加一个圆形,且支持圆形与圆形.圆形与矩形.矩形与矩形间的连线.在这个过程中我们会发 ...

  9. C#  自定义特性属性 限制自定义字段 数据

    不知道怎么表达这个东西,先记录一下吧,如果你们有好的想法可以联系我,共同进步 /// <summary>        /// 自定义属性帮助类        /// </summa ...

  10. error Delete `␍`eslintprettier/prettier

    问题描述 今天提交代码的时候,控制台报的错误就有点吓人 分析问题 由于历史原因,windows下和linux(mac)下的文本文件的换行符不一致. 当我用windows电脑git操作代码的时候,如cl ...