6354 Everything Has Changed
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 (,) 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=,,⋯,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.
≤T≤, ≤m≤, −≤xi,yi≤, ≤R,ri≤ (i=,,⋯,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 −.
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 -
- - Sample Output
81.62198908430238475376 Source
Multi-University Training Contest Recommend
chendu | We have carefully selected several similar problems for you:
板子题,注意内切要算。以及判断优劣弧的时候。用距离或者是弦的左右来判断。
我写的时候对优劣弧的定义弄反了,没改。我用的距离判断。
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define eps 1e-9
#define pi acos(-1.0)
struct point
{
double x,y;
};
struct yuan
{
point a;
double r;
};
typedef struct point point;
double xmult(point p1,point p2,point p0)
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
double distance(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
//点到直线的距离
double disptoline(point p,point l1,point l2)
{
return fabs(xmult(p,l1,l2))/distance(l1,l2);
}
//求两直线交点
point intersection(point u1,point u2,point v1,point v2)
{
point ret=u1;
double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))
/((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));
ret.x+=(u2.x-u1.x)*t;
ret.y+=(u2.y-u1.y)*t;
return ret;
}
int intersect_circle_circle(point c1,double r1,point c2,double r2)
{
return distance(c1,c2)<r1+r2&&distance(c1,c2)>fabs(r1-r2);
}
void intersection_line_circle(point c,double r,point l1,point l2,point& p1,point& p2)
{
point p=c;
double t;
p.x+=l1.y-l2.y;
p.y+=l2.x-l1.x;
p=intersection(p,c,l1,l2);
t=sqrt(r*r-distance(p,c)*distance(p,c))/distance(l1,l2);
p1.x=p.x+(l2.x-l1.x)*t;
p1.y=p.y+(l2.y-l1.y)*t;
p2.x=p.x-(l2.x-l1.x)*t;
p2.y=p.y-(l2.y-l1.y)*t;
}
void intersection_circle_circle(point c1,double r1,point c2,double r2,point& p1,point& p2)
{
point u,v;
double t;
t=(+(r1*r1-r2*r2)/distance(c1,c2)/distance(c1,c2))/;
u.x=c1.x+(c2.x-c1.x)*t;
u.y=c1.y+(c2.y-c1.y)*t;
v.x=u.x+c1.y-c2.y;
v.y=u.y-c1.x+c2.x;
intersection_line_circle(c1,r1,u,v,p1,p2);
}//两圆的交点
double simahdu(point a, point b,point c,double r)
{
double d=distance(a,b)*0.5;
double pp= *asin(d/r)*r;
return pp;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
double r;
scanf("%d%lf",&n,&r);
point ww;
ww.x=;ww.y=;
double ans=2.0*pi*r;
for(int i=;i<=n;i++)
{
point qq;
double qr;
scanf("%lf%lf%lf",&qq.x,&qq.y,&qr);
int ppp= intersect_circle_circle(ww,r,qq,qr);
if(distance(qq,ww)==fabs(qr-r))
{
ans=ans+*pi*qr;
}
if(ppp==)
{
point jiao1,jiao2;
intersection_circle_circle(qq,qr,ww,r,jiao1,jiao2);
point zd;
zd.x=(jiao1.x+jiao2.x)/;
zd.y=(jiao1.y+jiao2.y)/;
double l1=distance(ww,qq);
double l2=distance(ww,zd);
double l3=distance(qq,zd);
double jiayou=simahdu(jiao1,jiao2,qq,qr);
double jialie=2.0*pi*qr-jiayou;
double jianyou=simahdu(jiao1,jiao2,ww,r);
double jianlie=2.0*pi*r-jianyou;
if(l1>l2 && l1>l3)//加优减优
{
ans=ans+jiayou-jianyou; }
else if(l3 > l2)//加优减劣
{
ans=ans+jiayou-jianlie;
}
else//加劣减优
{
ans=ans+jialie-jianyou; } }
else
{
continue;
} }
printf("%0.20lf\n",ans);
}
return ;
}
6354 Everything Has Changed的更多相关文章
- HDU 6354 Everything Has Changed(余弦定理)多校题解
题意:源点处有个圆,然后给你m个圆(保证互不相交.内含),如果源点圆和这些原相交了,就剪掉相交的部分,问你最后周长(最外面那部分的长度). 思路:分类讨论,只有内切和相交会变化周长,然后乱搞就行了.题 ...
- HDU 6354.Everything Has Changed-简单的计算几何、相交相切圆弧的周长 (2018 Multi-University Training Contest 5 1005)
6354.Everything Has Changed 就是计算圆弧的周长,总周长=大圆周长+相交(相切)部分的小圆的弧长-覆盖掉的大圆的弧长. 相交部分小圆的弧长直接求出来对应的角就可以,余弦公式, ...
- CentOS:ECDSA host key "ip地址" for has changed and you have requested strict checking(转)
原文地址:http://blog.csdn.net/ausboyue/article/details/52775281 Linux SSH命令错误:ECDSA host key "ip地址& ...
- 【异常】INFO: TopologyManager: EndpointListener changed ...
5月份做云部署,在调试CSS系统时,出现启动系统时,卡死情况,后台日志如下: May 03, 2016 2:34:52 AM org.apache.cxf.dosgi.topologymanager. ...
- tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end w ...
- Centos 7 mysql Buffered warning: Changed limits: max_connections: 214 解决方法
Everytime I restart MySQL I have this warning: [Warning] Buffered warning: Changed limits: max_conne ...
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
原文地址:http://linuxme.blog.51cto.com/1850814/375752 今天将阿里云服务器更换了一下系统盘,重启成功后,再次通过终端访问阿里云的公网IP报以下信息: @@@ ...
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED解决方法
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATION ...
- 详细!交叉编译时 note: the mangling of 'va_list' has changed in GCC 4.4解决办法
为什么要在标题前面加了详细两个字,就是为了吸引看文章的你还有写文章的我这种小白,我是从坑里面爬出来了. 废话少说.... 问题就是这样子了,至于解决办法,在网上搜索了很久,大多数以一段英文作为解决办法 ...
随机推荐
- [转载]Oracle用户创建及权限设置
出处:https://www.cnblogs.com/buxingzhelyd/p/7865194.html 权限: create session 允许用户登录数据库权限 create table ...
- 融云通信云发力教育行业 助在线教育"风口"继续腾云
4 月 16 日,2019 年AI 在线教育大会在北京站圆满落幕,会上云集超过500位资深教育从业者.200 家机构,共同就 AI 教育落地.在线教育应用经验等主题开展深入探讨.云通信领域的领导企业融 ...
- zigbee组网函数的一些用法
1.NLME_PermitJoiningRequest(0) :(1)值0x00:表示禁止加入网络 (2)值0x01-0xFE:表示允许链接的秒数 (3) 值0xff:表示启用网络 同时此函数:是 ...
- 论文笔记【四】Semi-supervised Word Sense Disambiguation with Neural Models
基于神经模型的半监督词义消歧 Dayu Yuan Julian Richardson Ryan Doherty Colin Evans Eric Altendorf Google, Mount ...
- sourceTree 代码冲突解决
1.代码提交,有冲突 2. 拉取未同步的代码,勾选用衍合代替合并. 3. 在工作副本,未提交代码显示 4. 冲突代码解决 5. sourcetree页面
- iOS项目之iPhoneX遇到的坑
问题一: 今天升级到Xcode 9.0,里面多了iPhone 8,iPhone 8P,iPhone X三款手机模拟器,而且发现最多可以同时运行五个模拟器.但随之而来的问题也出现了,就是 iPhone ...
- Java笔记 #06# 自定义简易参数校验框架——EasyValidator
索引 一.校验效果演示 二.校验器定义示例 定义一个最简单的校验器 正则校验器 三.EasyValidator的实现 四.更好的应用姿势——配合注解和面向切面 “参数校验”属于比较无聊但是又非常硬性的 ...
- pandas替换一列中的汉字为数字
表格的一列“总金额”应该全部为数字,但其中少数项出现汉字,应该将汉字替换为数字,才能进行后面的计算. 先定义一个函数: def is_number(s): try: float(s) return T ...
- bat实现往hosts文件追加内容
做个笔记. @echo off ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: ...
- Developing Vert.x Modules using the Standard Project
The module The tests Unit tests Integration tests Java integration tests JavaScript integration test ...