-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11662.cpp
43 lines (35 loc) · 1002 Bytes
/
11662.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
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
int xxxx[]={-1,0,1,0,-1,1,1,-1};
int yyyy[]={0,1,0,-1,-1,1,-1,1};
void solve(){
long double Ax,Ay,Bx,By,Cx,Cy,Dx,Dy;cin>>Ax>>Ay>>Bx>>By>>Cx>>Cy>>Dx>>Dy;
long double result = 1e9;
for (long double i = 0; i <= 5e5; i++) {
long double x1 = Ax + (Bx - Ax) / 5e5 * i;
long double y1 = Ay + (By - Ay) / 5e5 * i;
long double x2 = Cx + (Dx - Cx) / 5e5 * i;
long double y2 = Cy + (Dy - Cy) / 5e5 * i;
result = min(
result,
sqrt((x1-x2) * (x1-x2) + (y1 - y2) * (y1 - y2))
);
}
printf("%.10Lf", result);
}
int main()
{
// cin.tie(0)->sync_with_stdio(false);
int T=1;
// cin >>T;
while (T--) {
solve();
cout << '\n';
}
return 0;
}