zoukankan      html  css  js  c++  java
  • 训练赛第三场A题 zoj 559

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2559

    解题报告:比赛的时候的想法是可以确定至少有两对相切的圆,所以我的做法是枚举其中的两对圆相切,还好,这样只要枚举3次就够 了,然后设其中一个圆的半径为x,然后其他的两个圆的半径就知道了,然后另外一条边的边长减去这条边上的两个圆的半径等于0就可以得出x也就求出了三条边的大小,然后求出这三种情况下的半径的总和是多少,输出最大的那种情况下的三个半径的长度就是了。还要注意的是输出的顺序,要按照输入的顺序输出。

     1 #include<cstdio>
     2 #include<cmath>
     3 #include<iostream>
     4 #include<algorithm>
     5 
     6 
     7 double dis(double x1,double y1,double x2,double y2)
     8 {
     9     return std::sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    10 }
    11 
    12 int main()
    13 {
    14     double x1,y1,x2,y2,x3,y3,a,b,c;
    15 
    16     while(scanf("%lf%lf",&x1,&y1)!=EOF)
    17     {
    18         scanf("%lf%lf%lf%lf",&x2,&y2,&x3,&y3);
    19         a = dis(x1,y1,x2,y2);
    20         b = dis(x1,y1,x3,y3);
    21         c = dis(x2,y2,x3,y3);
    22         double tot[4],X1,X2,X3;
    23         X1 = (b + c - a) / 2.0;
    24         X2 = (a + c - b) / 2.0;
    25         X3 = (a + b - c) / 2.0;
    26         tot[0] = b + c - X1;
    27         tot[1] = a + c - X2;
    28         tot[2] = a + b - X3;
    29         if(tot[0] >= tot[1] && tot[0] >= tot[2])
    30         printf("%.6lf
    %.6lf
    %.6lf
    ",b - X1,c - X1,X1);
    31         else if(tot[1] >= tot[0] && tot[1] >= tot[2])
    32         printf("%.6lf
    %.6lf
    %.6lf
    ",a - X2,X2,c - X2);
    33         else printf("%.6lf
    %.6lf
    %.6lf
    ",X3,a - X3,b - X3);
    34     }
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    五种I/O模型
    Python socket服务
    Python 协程
    python openpyxl 简单使用
    python 文件夹压缩
    Python 多进程
    MySQL 自定义函数
    python 队列
    python 多线程、线程锁、事件
    python paramiko模块:远程连接服务器
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3304442.html
Copyright © 2011-2022 走看看