largest circle define _CRT_SECURE_NO_WARNI NGS include iostream includ

 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
//largest circle//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#define ll long long
#define eps 1e-6
#define all(x) x.begin(), x.end()
#define Cout cout << fixed << setprecision(6)
const double pi = acos(-1.0);
using namespace std;
struct v2 {
double x, y;
v2() {}
v2(double _x, double _y) : x(_x), y(_y) {}
inline v2 operator -(const v2 &a) const { return v2(x - a.x, y - a.y); }
inline v2 operator +(const v2 &a) const { return v2(x + a.x, y + a.y); }
inline v2 operator *(double a) const { return v2(a * x, a * y); }
};
inline double dot(const v2& a, const v2& b) { return a.x * b.x + a.y * b.y; }
inline double cross(const v2& a, const v2& b) { return a.x * b.y - a.y * b.x; }
inline double dist2(const v2&a, const v2& b) { return dot(a - b, a - b); }
double w, h;
vector <v2> g(4);
inline double dist(const v2& a) {
v2 p = g[0] + (g[3] - g[0]) * (a.x / w);
v2 q = g[1] + (g[2] - g[1]) * (a.x / w);
v2 b = p + (q - p) * (a.y / h);
return dist2(a, b);
}
inline void modif(v2& a) {
v2 p = g[0] + (g[3] - g[0]) * (a.x / w);
v2 q = g[1] + (g[2] - g[1]) * (a.x / w);
a = p + (q - p) * (a.y / h);
}
int main(){
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
//freopen( "output.txt", "w", stdout);
#endif
cin >> w >> h;
for (int i = 0; i < 4; ++i)
cin >> g[i].x >> g[i].y;
v2 a = v2(0, 0);
for (int i = 0; i < 30; ++i) {
modif(a);
}
double ans = dist(a);
if (ans < eps)
Cout << a.x << " " << a.y << endl;
else
cout << "NONE" << endl;
return 0;
}