hdu 6354
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.

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).
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.
4 10
6 3 5
10 -4 3
-2 -4 4
0 9 1
#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的更多相关文章
- HDU 6354.Everything Has Changed-简单的计算几何、相交相切圆弧的周长 (2018 Multi-University Training Contest 5 1005)
6354.Everything Has Changed 就是计算圆弧的周长,总周长=大圆周长+相交(相切)部分的小圆的弧长-覆盖掉的大圆的弧长. 相交部分小圆的弧长直接求出来对应的角就可以,余弦公式, ...
- HDU 6354 Everything Has Changed(余弦定理)多校题解
题意:源点处有个圆,然后给你m个圆(保证互不相交.内含),如果源点圆和这些原相交了,就剪掉相交的部分,问你最后周长(最外面那部分的长度). 思路:分类讨论,只有内切和相交会变化周长,然后乱搞就行了.题 ...
- HDU 6351暴力枚举 6354计算几何
Beautiful Now Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)T ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- Vue双向绑定简单实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- c#基础_ArrayList
list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); //list.AddRange(list); //list.Clear();清空所有元素 ...
- go实现set
package main import ( "fmt" "sync" ) type object interface{} type Set struct { m ...
- html5响应式
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = ‘orientationchange’ in window ? ...
- Echarts的重点
官网中,主要看文档的”教程“和”配置项手册“这两部分 1 下载 引入js 页面放一个容器,一定要设宽高 创建对象:var myChart = echarts.init(document.getElem ...
- [转] java实现https请求
package com.lichmama.test.util; import java.io.ByteArrayOutputStream; import java.io.IOException; im ...
- 洛谷 P2983 [USACO10FEB]购买巧克力Chocolate Buying
购买巧克力Chocolate Buying 乍一看以为是背包,然后交了一个感觉没错的背包上去. #include <iostream> #include <cstdio> #i ...
- ios 根据字典自动生成属性
- (void)createPropertyCode{ NSMutableString *codes = [NSMutableString string]; // 遍历字典 [self enumera ...
- [PCL]对‘pcl::visualization::CloudViewer::CloudViewer(std::string const&)’未定义的引用
pcl::visualization::CloudViewer viewer("Cloud Viewer"); 这个时候报错. 试了很多方法,有人说,targe t_link 时候 ...
- Lodash.js常用拷贝
lodash.js 降低 array.number.objects.string 等等的使用难度从而让 JavaScript 变得更简单.非常适用于:遍历 array.object 和 string: ...