Everything Has Changed ( HDU 6354 )

博客围绕机械臂切割圆盘的工作展开,将操作平面设为二维坐标系,初始有中心为(0,0)、半径为R的圆盘,m个机械臂同时切割,每个切割区域是一个圆。任务是计算圆盘剩余区域的外周长,还给出了输入输出的格式及要求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)(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 

题意:求红色的周长。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define MAX 0x3f3f3f3f
#define fori(a,b) for(int i=a;i<=b;i++)
#define forj(a,b) for(int j=a;j<=b;j++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int M=1e6+10;
const int mod=1e9+7;
int main()
{
    int i,j,T,m;
    double r,R,x,y;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d %lf",&m,&R);
        double ans=2.0*PI*R;
        while(m--){
            scanf("%lf%lf%lf",&x,&y,&r);
            double d=sqrt(x*x + y*y);
            if(R-r == d){//内切
                ans+= 2.0*PI*r;
            }
            else if(R-r<d && R+r>d){
                double d1;//大圆的弦心距
                d1=(double)(R*R-r*r+d*d)/(2.0*d);
                ans-=2.0*R*acos(d1/R);
                ans+=2.0*r*acos((d-d1)/r);
            }
        }
        printf("%.20lf\n",ans);
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值