题目链接:点击打开链接
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const long double eps = 1e-13;
#define y1 Y1
long double area(long double x1, long double y1, long double x2, long double y2) {
return x1*y2-x2*y1;
}
long double dist(long double x1, long double y1, long double x2, long double y2) {
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
void work(long double x1, long double y1, long double x2, long double y2, long double d) {
long double dx = x2 - x1, dy = y2 - y1;
long double k = sqrt((dx * dx + dy * dy)/ d / d);
cout << setprecision(20) << (dx / k + x1 + eps) << " " << (dy / k + y1 + eps) << endl;
//printf("%.12f %.12f\n", dx / k + x1 + eps, dy / k + y1 + eps);
}
long double x1, x2, x3;
long double y1, y2, y3;
int main() {
while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3) {
long double a = dist(x2, y2, x3, y3);
long double b = dist(x1, y1, x3, y3);
long double c = dist(x1, y1, x2, y2);
long double l = a+b+c;
long double ansx, ansy;
if(l*l-8*a*b > -eps) {
ansx = (l - sqrt(l*l-8*a*b))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx < a + eps && ansy > eps && ansy < b + eps) {
puts("YES");
work(x3, y3, x2, y2, ansx);
work(x3, y3, x1, y1, ansy);
continue;
}
ansx = (l + sqrt(l*l-8*a*b))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx < a + eps && ansy > eps && ansy < b + eps) {
puts("YES");
work(x3, y3, x2, y2, ansx);
work(x3, y3, x1, y1, ansy);
continue;
}
}
if(l*l-8*a*c > -eps) {
ansx = (l - sqrt(l*l-8*a*c))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx < a+ eps && ansy > eps && ansy < c+ eps) {
puts("YES");
work(x2, y2, x3, y3, ansx);
work(x2, y2, x1, y1, ansy);
continue;
}
ansx = (l + sqrt(l*l-8*a*c))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx <= a && ansy > eps && ansy <= c) {
puts("YES");
work(x2, y2, x3, y3, ansx);
work(x2, y2, x1, y1, ansy);
continue;
}
}
if(l*l-8*c*b > -eps) {
ansx = (l - sqrt(l*l-8*c*b))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx <= c && ansy > eps && ansy <= b) {
puts("YES");
work(x1, y1, x2, y2, ansx);
work(x1, y1, x3, y3, ansy);
continue;
}
ansx = (l + sqrt(l*l-8*c*b))/4.0;
ansy = l / 2.0 - ansx;
if(ansx > eps && ansx <= c && ansy > eps && ansy <= b) {
puts("YES");
work(x1, y1, x2, y2, ansx);
work(x1, y1, x3, y3, ansy);
continue;
}
}
puts("NO");
}
return 0;
}