1 条题解
-
0
#include <bits/stdc++.h> using namespace std; typedef double db; const db eps = 1e-4; struct Complex { db a, b; Complex () {} Complex (db _a, db _b = 0) : a(_a), b(_b) {} friend Complex operator + (const Complex &c1, const Complex &c2) { return Complex(c1.a + c2.a, c1.b + c2.b); } friend Complex operator - (const Complex &c1, const Complex &c2) { return Complex(c1.a - c2.a, c1.b - c2.b); } friend Complex operator * (const Complex &c1, const Complex &c2) { return Complex(c1.a * c2.a - c1.b * c2.b, c1.a * c2.b + c1.b * c2.a); } friend Complex operator / (const Complex &c1, const Complex &c2) { double modulus = c2.a * c2.a + c2.b * c2.b; return Complex((c1.a * c2.a + c1.b * c2.b) / modulus, (c1.b * c2.a - c1.a * c2.b) / modulus); } friend bool operator == (const Complex &c1, const Complex &c2) { return fabs(c1.a - c2.a) < eps && fabs(c1.b - c2.b) < eps; } } A, B, C, p[3]; bool calc (const Complex _A, const Complex _B, const Complex _C) { Complex T = (_A - _B) / (A - B), P = (A * T - _A) / (T - 1); if ((C - P) * T == (_C - P)) { printf("%lf %lf\n", P.a, P.b); return 1; } return 0; } int T; int main () { for (scanf("%d", &T); T; --T) { scanf("%lf%lf%lf%lf%lf%lf", &A.a, &A.b, &B.a, &B.b, &C.a, &C.b); scanf("%lf%lf%lf%lf%lf%lf", &p[0].a, &p[0].b, &p[1].a, &p[1].b, &p[2].a, &p[2].b); if (calc(p[0], p[1], p[2])) { continue; } if (calc(p[0], p[2], p[1])) { continue; } if (calc(p[1], p[0], p[2])) { continue; } if (calc(p[1], p[2], p[0])) { continue; } if (calc(p[2], p[0], p[1])) { continue; } if (calc(p[2], p[1], p[0])) { continue; } } return 0; }
- 1
信息
- ID
- 5286
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 2
- 已通过
- 1
- 上传者