Everything Has ChangedTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 461 Accepted Submission(s): 261 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.
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 .
Sample Input 1 4 10 6 3 5 10 -4 3 -2 -4 4 0 9 1
Sample Output 81.62198908430238475376
Source 2018 Multi-University Training Contest 5
Recommend chendu | We have carefully selected several similar problems for you: 6361 6360 6359 6358 6357 |
#include<iostream>
#include<algorithm>
#include<string>
#include<map>//int dx[4]={0,0,-1,1};int dy[4]={-1,1,0,0};
#include<queue>//int gcd(int a,int b){return b?gcd(b,a%b):a;}
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#define mod 1e9+7
#define ll unsigned long long
#define MAX 1000000000
#define ms memset
#define maxn 20
using namespace std;
const double pi=acos(-1.0);
/*
题目大意:给定一个大圆,和m个小圆,
按图求周长。
掌握了余弦定理就简单了,
先判断其是否和圆有交点,
外切不计算,内切计算。
统计一下,注意精度
*/
int m;
double x,y,d,r;
double dist(double x,double y)
{
return sqrt(x*x+y*y);
}
double yuxian(double r1,double r2,double r3)
{
///cout<<r1<<" "<<r2<<endl;
double ans= (r1*r1+r2*r2-r3*r3)/(2.0*r1*r2);
return ans;
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
scanf("%d%lf",&m,&r);
double len=2.0*pi*r;
for(int i=0;i<m;i++)
{
scanf("%lf%lf%lf",&x,&y,&d);
double dis=dist(x,y);
if(dis>=d+r) continue;
if(dis+d<r) continue;
len=len-2.0*r*acos(yuxian(r,dis,d));
len=len+2.0*d*acos(yuxian(d,dis,r));
}
///cout<<len<<endl;
printf("%.10f\n",len);
}
return 0;
}