Everything Has Changed
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Special Judge
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
题意:有一个圆心坐标为(0,0)的圆,有n个不相交的圆对这个圆进行切割,求这个圆切割后的外周长
题解:弧长公式:
余弦公式求出余弦,反余弦( acos())求出弧度制表示的角,根据上面公式 可以直接求出弧长。加减运算一下。
公式中n是圆心角度数,r是半径,I为弧长。
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<typeinfo>
#include<string>
#include<queue>
#include<bitset>
#include<set>
#include<stack>
#include<map>
using namespace std;
#define LL long long
#define scand(x) scanf("%d",&x)
#define scandd(x,y) scanf("%d%d",&x,&y)
#define scans(x) scanf("%s",x);
#define scanld(x) scanf("%lld",&x)
#define rep(i,x,n) for(int i = x;i < n;i++)
#define dep(i,x,n) for(int i = x;i > n;i--)
#define pi 3.141592653589793238462643383249901429
int main()
{
int T;
scand(T);
while(T--)
{
int q;
double r;
double x0,y0,r0;
scanf("%d%lf",&q,&r);
double sizelen = 2 * pi * r;
rep(i,0,q)
{
scanf("%lf%lf%lf",&x0,&y0,&r0);
double length = sqrt(x0 * x0 + y0 * y0);
if((r + r0) >= length && length >= abs(r - r0))
{
double ai = (r0 * r0 + x0 * x0 + y0 * y0 - r * r)/(2.0 * r0 * length);
ai = acos(ai);
sizelen += 2 * ai * r0;
double di = (r * r + x0 * x0 + y0 * y0 - r0 * r0)/(2.0 * r * length);
di = acos(di);
sizelen -= 2 * di * r;
}
}
printf("%.12lf\n",sizelen);
}
}