2020 cattle off winter training camp algorithm base 6 J sign problem

Links: https://ac.nowcoder.com/acm/contest/3007/J
Title Description

Existing a side length of the triangle is a positive integer, asked whether its three vertices of a circle draw three circles, so that the two three round cut the two outer

Trilateral length of no more than10^{8}

 Thinking

First determines whether a triangle, the difference is less than the third side, or both sides of the edge are greater than the third line, and then can be assumed tangent to three sides each having a length r1,r2,r3, then there r1+r2=a,r1+r3=b,r2+r3=cmay be three radii find out, if the three there is less than a radius equal to 0, it is not feasible, otherwise feasible

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (abs(a - b) >= c || abs(a - c) >= b || abs(b - c) >= a){
        printf("wtnl\n");
        return 0;
    }
    double x, y, z;
    x = a;
    y = b;
    z = c;
    double r1, r2, r3;
    r1 = x + y - z;
    r2 = x + z - y;
    r3 = y + z - x;
    r1 /= 2;
    r2 /= 2;
    r3 /= 2;
    if (r1 > 0 && r2 > 0 && r3 > 0){
        if (r1 > r2)swap(r1, r2);
        if (r1 > r3)swap(r1, r3);
        if (r2 > r3)swap(r2, r3);
        printf("Yes\n%.2lf %.2lf %.2lf\n", r1, r2, r3);
    }
    else printf("No\n");
    return 0;
}

 

Published 204 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43701790/article/details/104332186