zoukankan      html  css  js  c++  java
  • hdu 6354 Everything Has Changed

    18年杭电多校5的e题

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6354

    根据题意,第一个以后的圆不会相交,所以思路直接是通过余弦定理计算角度,然后求出弧长,进行加减得出答案。

    代码:

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <algorithm>
     5 #include <cmath>
     6 using namespace std;
     7 const double pi = acos(-1.0);
     8 
     9 double dis(double x,double y){
    10     double distance = sqrt(x*x+y*y);
    11     return distance;
    12 }
    13 
    14 int main()
    15 {
    16     int t;
    17     cin>>t;
    18     while(t--){
    19         int m;
    20         double x,y,r,r0;
    21         scanf("%d %lf",&m,&r0);
    22         double L = 2*pi*r0;
    23         while(m--){
    24             scanf("%lf %lf %lf",&x,&y,&r);
    25             double distance = dis(x,y);
    26             int dist1 = r0 + r;
    27             int dist2 = r0 - r;
    28             if(distance>=dist2&&distance<dist1) {
    29                 double angela = acos((r0*r0 + distance*distance - r*r)/(2*distance*r0));
    30                 double angelb = acos((r*r + distance*distance - r0*r0)/(2*distance*r));
    31                 L -= 2*angela*r0;
    32                 L += 2*angelb*r;
    33             }
    34         }
    35         printf("%.20lf
    ",L);
    36     }    
    37     return 0;
    38 }
    View Code

     想起忘记写这题的自闭过程了

    改了快三个小时(

    最后发现没有写换行

    以后一定要注意QAQ

  • 相关阅读:
    python 2
    Python 1 practice
    python 1
    Python多线程_笔记
    背景自适应不会随浏览器界面放大速效而改变
    平行四边形定理
    动态规划3(区间+树形)
    素数快速生成
    设CPU共有16根地址线,8根数据线,,,
    贪心+huffman编码+模拟退火+分治
  • 原文地址:https://www.cnblogs.com/moomight/p/11246700.html
Copyright © 2011-2022 走看看