zoukankan      html  css  js  c++  java
  • E

     
    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. 
    1T10001≤T≤1000, 1m1001≤m≤100, 1000xi,yi1000−1000≤xi,yi≤1000, 1R,ri10001≤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 10610−6.
    Formally, let your answer be aa and the jury's answer be bb. Your answer is considered correct if |ab|max(1,|b|)106|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


     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <algorithm>
     4 #include <cmath>
     5 #include <math.h>
     6 #include <cstring>
     7 #include <string>
     8 #include <queue>
     9 #include <deque>
    10 #include <stack>
    11 #include <stdlib.h>
    12 #include <list>
    13 #include <map>
    14 #include <utility>
    15 #include <time.h>
    16 #include <set>
    17 #include <bitset>
    18 #include <vector>
    19 #define ms(a,b) memset(a,b,sizeof(a))
    20 #define ll long long
    21 
    22 using namespace std;
    23 
    24 const int maxn = 100+10;
    25 const int INF = 0x3f3f3f3f;
    26 
    27 double dis(double x1,double y1){
    28     return sqrt(x1 * x1 + y1 * y1);
    29 }
    30 int main(){
    31     int t;
    32     double pi = acos(-1.0);
    33     char n[12];
    34     cin >> t;
    35     while(t--){
    36        double ans;
    37        double R;
    38        int m;
    39        cin >> m;
    40        scanf ("%lf",&R);
    41        ans = 2 * R * pi;
    42        while(m--)
    43        {
    44            double x,y,r;
    45            scanf("%lf%lf%lf",&x,&y,&r);
    46            double dist = dis(x,y);
    47            if(dist + r == R)
    48            {
    49                 ans += 2 * r * pi;
    50            }
    51            else if(dist >= r + R || dist + r < R)
    52            {
    53                 continue;
    54            }
    55            else
    56            {
    57                 double del = acos((R * R + dist * dist - r * r) / (2 * dist * R));
    58                 double si = acos((r * r + dist * dist - R * R) / (2 * dist * r));
    59                 ans = ans - del * R * 2 + si * r * 2;
    60             }
    61        }
    62        printf("%lf
    ",ans);
    63     }
    64     return 0;
    65 }        
    View Code

    作者:YukiRinLL

    出处:YukiRinLL的博客--https://www.cnblogs.com/SutsuharaYuki/

    您的支持是对博主最大的鼓励,感谢您的认真阅读。

    本文版权归作者所有,欢迎转载,但请保留该声明。

  • 相关阅读:
    1124 vue路由配置初级实践&和npm run dev干嘛了
    1130 携程网焦点图+导航栏,flex布局实践
    1124 在vscode中快速创建vue模板
    122 携程网案例flex布局第三部分
    128 手撸轮播组件瞬时切换版本,布局部分
    1125 vscode自定义快捷键扩展选择单词等
    124 本地服务器搭建
    1128 defineProperty中getter和setter的用法
    2216 怎么快速打开powershell
    Visual Studio 2010的网站局域网发布功能(Publish)
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/11301498.html
Copyright © 2011-2022 走看看