-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccc01s4.cpp
57 lines (57 loc) · 1.4 KB
/
ccc01s4.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*find largest circle that encompasses all points*/
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int n;
cin>>n;
double x[n],y[n];
double a,b,c,d,s,ans;
for (int i=0;i<n;i++)
{
cin>>x[i];
cin>>y[i];
}
ans =0;
for (int i=0;i<n;i++)
{
for (int j=i+1;j<n;j++)
{
for (int k=j+1;k<n;k++)
{
a = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
b = sqrt((x[j]-x[k])*(x[j]-x[k])+(y[j]-y[k])*(y[j]-y[k]));
c = sqrt((x[k]-x[i])*(x[k]-x[i])+(y[k]-y[i])*(y[k]-y[i]));
s = (a+b+c)/2;
d = 0;
if ((s==0) or (a*a+b*b-c*c<0) or (c*c+b*b-a*a<0) or (a*a+c*c-b*b<0))
{
if (a>d)
{
d = a;
}
if (b>d)
{
d = b;
}
if (c>d)
{
d = c;
}
}
else
{
d = 2*(a*b*c)/(4*sqrt(s*(s-a)*(s-b)*(s-c)));
}
if (d>ans)
{
ans = d;
}
}
}
}
cout<<setprecision(2)<<fixed<<ans;
}