#include #include #include #include using namespace std; struct P { double x, y, z; P(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {} }; P operator-(P a, P b) { return P(a.x - b.x, a.y - b.y, a.z - b.z); } P operator*(P a, double b) { return P(a.x * b, a.y * b, a.z * b); } P operator/(P a, double b) { return P(a.x / b, a.y / b, a.z / b); } double dot(P a, P b) { return a.x*b.x + a.y*b.y + a.z*b.z; } double abs(P a) { return sqrt(a.x*a.x + a.y*a.y + a.z*a.z); } P normalize(P a) { return a / abs(a); } P proj(P a, P b) { a = normalize(a); return a * dot(a, b); } int main() { vector

ps(4); for (int i = 0; i < 4; i++) { double x, y, z; cin >> x >> y >> z; ps[i] = P(x, y, z); } double len = dot(normalize(ps[1] - ps[0]), ps[2] - ps[0]) / abs(ps[1] - ps[0]); P c = (ps[2] - ps[0]) - proj(ps[1] - ps[0], ps[2] - ps[0]); double u = dot(normalize(ps[1] - ps[0]), ps[3] - ps[0]) / abs(ps[1] - ps[0]); double w = dot(normalize(c), ps[3] - ps[0]) / abs(c); // ps[2]-ps[0] = c + len(ps[1] - ps[0]) // c =ps[2] - ps[0] - len( ps[1] - ps[0] ) u -= len * w; double v = w; cerr << u << ' ' << v << endl; if (u >= 0 && v >= 0 && u + v <= 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } }