#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b void vprint(T &V){ for(auto v : V){ cout << v << " "; } cout << endl; } // 3次元ベクトル struct V3{ double x, y, z; V3(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {} }; V3 operator+(V3 a, V3 b) { return V3(a.x + b.x, a.y + b.y, a.z + b.z); } V3 operator-(V3 a, V3 b) { return V3(a.x - b.x, a.y - b.y, a.z - b.z); } V3 operator*(V3 a, double b) { return V3(a.x * b, a.y * b, a.z * b); } V3 operator*(double b, V3 a) { return V3(a.x * b, a.y * b, a.z * b); } V3 operator/(V3 a, double b) { return V3(a.x / b, a.y / b, a.z / b); } // 内積 double dot(V3 a, V3 b) { return a.x*b.x + a.y*b.y + a.z*b.z; } // 外積 V3 cross(V3 u, V3 v) { return V3((u.y * v.z - u.z * v.y), (u.z * v.x - u.x * v.z), (u.x * v.y - u.y * v.x)); } double abs(V3 a) { double len = sqrt(a.x*a.x + a.y*a.y + a.z*a.z); if(len==0){ cout << "warning"; } return sqrt(a.x*a.x + a.y*a.y + a.z*a.z); } V3 normalize(V3 a) { if(a.x==0 && a.y==0 && a.z==0){ return a; } return a / abs(a); } V3 proj(V3 a, V3 b) { a = normalize(a); return a * dot(a, b); } void printV3(V3 a){ cout << a.x << ' ' << a.y << ' ' << a.z << endl; } ll sign(double a){ if(a>=0){ return 1; }else{ return -1; } } // 点dは三角形内部にいるか bool in_triangle(V3 a, V3 b, V3 c, V3 d){ auto AB = b-a; auto BC = c-b; auto CA = a-c; auto AD = d-a; auto BD = d-b; auto CD = d-c; auto c0 = cross(AB, AD); auto c1 = cross(BC, BD); auto c2 = cross(CA, CD); auto dot0 = dot(c0, c1); auto dot1 = dot(c1, c2); auto dot2 = dot(c2, c0); if(sign(dot0)==sign(dot1) && sign(dot1)==sign(dot2)){ return true; }else{ return false; } } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input V3 V[4]; FOR(i, 0, 4){ cin >> V[i].x >> V[i].y >> V[i].z; } auto AA = V[0] - V[0]; auto AB = V[1] - V[0]; auto AC = V[2] - V[0]; auto n = cross(AB, AC); n = normalize(n); auto AD = V[3] - V[0]; auto a = AD; auto AE = a - dot(a, n) * n; bool f = in_triangle(AA, AB, AC, AE); if(f){ p_yes(); }else{ p_no(); } return 0; }