-
Notifications
You must be signed in to change notification settings - Fork 0
/
1C.cpp
178 lines (142 loc) · 3.08 KB
/
1C.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <bits/stdc++.h>
using namespace std;
typedef long long itype;
typedef long double ftype;
const ftype pi = acosl(-1); // 3.1415926535897932384626433832795l
const ftype radian = 180 / pi; // 57.295779513082320876798154814105l
const ftype eps = 1e-5l;
const int inf = 0x7f7f7f7f;
const long long infll = 0x7f7f7f7f7f7f7f7fll;
const ftype infl = 1e20l;
template <class T>
inline int sgn(const T & x)
{
return (x > eps) - (x < -eps);
}
template <class T>
inline T trigonometric(const T & x)
{
if (x < -1)
return -1;
else if (x < 1)
return x;
else
return 1;
}
#define Vector Point
template <class T>
class Point
{
public:
T x, y;
Point(void) : x(0), y(0)
{
}
Point(const T & x, const T & y) : x(x), y(y)
{
}
template <class S>
Point(const Point<S> & src) : x(src.x), y(src.y)
{
}
Vector operator + (const Vector & rhs) const
{
return Vector(x + rhs.x, y + rhs.y);
}
Vector operator - (const Vector & rhs) const
{
return Vector(x - rhs.x, y - rhs.y);
}
T length(void) const
{
return sqrtl(x * x + y * y);
}
T length2(void) const
{
return x * x + y * y;
}
T distance(const Point & rhs) const
{
return (rhs - *this).length();
}
T distance2(const Point & rhs) const
{
return (rhs - *this).length2();
}
Vector operator * (const T & rhs) const
{
return Vector(x * rhs, y * rhs);
}
Vector operator / (const T & rhs) const
{
return Vector(x / rhs, y / rhs);
}
T operator * (const Vector & rhs) const
{
return x * rhs.y - y * rhs.x;
}
T operator & (const Vector & rhs) const
{
return x * rhs.x + y * rhs.y;
}
T cross(const Point & lhs, const Point & rhs) const
{
return (lhs - *this) * (rhs - *this);
}
T operator ^ (const Vector & rhs) const
{
T l1 = length(), l2 = rhs.length();
if (sgn(l1) == 0 || sgn(l2) == 0)
return 0;
int s = sgn(*this * rhs);
T a = acosl(trigonometric((*this & rhs) / l1 / l2));
return s < 0 ? -a : a;
}
};
template <class T>
Point<T> bary(const Point<T> & A, const T & a, const Point<T> & B, const T & b, const Point<T> & C, const T & c)
{
return (A * a + B * b + C * c) / (a + b + c);
}
template <class T>
Point<T> circumcenter(const Point<T> & A, const Point<T> & B, const Point<T> & C)
{
T a = B.distance2(C), b = C.distance2(A), c = A.distance2(B);
return bary(A, a * (b + c - a), B, b * (c + a - b), C, c * (a + b - c));
}
int main(void)
{
ios::sync_with_stdio(false);
Point<long double> p[3];
for (int i = 0; i < 3; i++)
cin >> p[i].x >> p[i].y;
if (sgn(p[0].cross(p[1], p[2])) < 0)
reverse(p, p + 3);
auto o = circumcenter(p[0], p[1], p[2]);
long double a[3];
for (int i = 0; i < 3; i++)
{
a[i] = (p[i] - o) ^ (p[(i + 1) % 3] - o);
if (sgn(a[i]) < 0)
a[i] += pi * 2;
}
long double ans = o.distance2(p[0]) * pi;
for (int k = 3; k <= 100; k++)
{
bool flg = true;
for (int i = 0; i < 3; i++)
{
int v = a[i] * k / pi / 2 + eps;
if (sgn(a[i] - pi * 2 * v / k) != 0)
{
flg = false;
break;
}
}
if (flg)
ans = min(ans, o.distance2(p[0]) * k * sinl(pi / k) * cosl(pi / k));
}
cout << fixed << setprecision(20);
cout << ans << endl;
return 0;
}