Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.2 kB
2
Indexable
Never
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 105
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define MOD 100000000000007

using namespace std;
int x[maxn],n,y[maxn];
double p,s,ans = -MOD,a,b,c,ans1 = MOD;
void inp()
{
    cin >> n;
    For(i,1,n)
        cin >> x[i] >> y[i];
}

bool check(double a, double b, double c)
{
    if(a+b > c && a+c > b && b+c > a) return true;
    else return false;
}

double Tinh(int i, int j)
{
    double res = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
    return res;
}
double Rad(double a, double b, double c)
{
     p = (a + b + c)/2;
     s =sqrt(p*(p-a)*(p-b)*(p-c));
     double res = (a*b*c)/(4*s);
     return res;
}
void solve()
{
    for (int i = 1; i<=n-2; i++)
    for (int j = i+1; j<=n-1; j++)
    for (int k = j+1; k<=n; k++)
    {
        a = Tinh(i,j); b = Tinh(j,k); c = Tinh(i,k);
        if(check(a,b,c))
        {
             ans = max({ans,a/2,b/2,c/2});
             ans1 = min(ans1,Rad(a,b,c));

        }
    }
    cout << fixed << setprecision(3) << min(ans,ans1);
}
int main()
{
ios_base:: sync_with_stdio(0);
cin.tie(0);
if(fopen("bai1.inp","r")){
    freopen("bai1.inp","r",stdin);
}
inp();
solve();
}
Leave a Comment