This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub Luzhiled/comp-geometry
// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/CGL_7_C // verification-helper: ERROR 0.000001 #include "src/real-geometry/circle-lib/circumscribed-circle.hpp" #include "src/real-geometry/class/circle.hpp" #include "src/real-geometry/class/point.hpp" #include "src/real-geometry/utility/io-set.hpp" #include <iostream> int main() { using R = long double; geometry::point<R> a, b, c; std::cin >> a >> b >> c; geometry::circle<R> cir = geometry::circumscribed_circle(a, b, c); std::cout << cir.o.x() << " " << cir.o.y() << " " << cir.r << std::endl; }
#line 1 "test/aoj/cgl/7_C.test.cpp" // verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/CGL_7_C // verification-helper: ERROR 0.000001 #line 2 "src/real-geometry/circle-lib/circumscribed-circle.hpp" #line 2 "src/real-geometry/class/circle.hpp" #line 2 "src/real-geometry/class/point.hpp" #line 2 "src/real-geometry/class/vector.hpp" #include <complex> #include <iostream> namespace geometry { template< typename R > class vec2d : public std::complex< R > { using complex = std::complex< R >; public: using complex::complex; vec2d(const complex &c): complex::complex(c) {} const R x() const { return this->real(); } const R y() const { return this->imag(); } friend vec2d operator*(const vec2d &v, const R &k) { return vec2d(v.x() * k, v.y() * k); } friend vec2d operator*(const R &k, const vec2d &v) { return vec2d(v.x() * k, v.y() * k); } friend std::istream &operator>>(std::istream &is, vec2d &v) { R x, y; is >> x >> y; v = vec2d(x, y); return is; } }; } #line 4 "src/real-geometry/class/point.hpp" #include <vector> namespace geometry { template< typename R > using point = vec2d<R>; template< typename R > using points = std::vector< point< R > >; } #line 4 "src/real-geometry/class/circle.hpp" #line 6 "src/real-geometry/class/circle.hpp" // circle namespace geometry { template< typename R > class circle { public: point<R> o; R r; circle() = default; circle(point<R> o, R r) : o(o), r(r) {} const point<R> center() const { return o; } const R radius() const { return r; } }; template< typename R > using circles = std::vector< circle<R> >; } #line 2 "src/real-geometry/operation/cross-product.hpp" #line 4 "src/real-geometry/operation/cross-product.hpp" namespace geometry { template< typename R > R cross_product(const vec2d<R> &a, const vec2d<R> &b) { return a.x() * b.y() - a.y() * b.x(); } } #line 6 "src/real-geometry/circle-lib/circumscribed-circle.hpp" namespace geometry { template< typename R > circle<R> circumscribed_circle(const point<R> &a, const point<R> &b, const point<R> &c) { R A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b); R S = std::norm(cross_product<R>(b - a, c - a)); R T = A + B + C; point<R> o{(A*(T - 2*A) * a + B*(T - 2*B) * b + C*(T - 2*C) * c) / (4 * S)}; return circle(o, std::abs(o - a)); } } #line 2 "src/real-geometry/utility/io-set.hpp" #include <iomanip> namespace geometry { class IoSetup { using u32 = unsigned int; void set(std::ostream &os, u32 precision) { os << std::fixed << std::setprecision(precision); } public: IoSetup(u32 precision = 15) { std::cin.tie(0); std::ios::sync_with_stdio(0); set(std::cout, precision); set(std::cerr, precision); } } iosetup; } #line 8 "test/aoj/cgl/7_C.test.cpp" #line 10 "test/aoj/cgl/7_C.test.cpp" int main() { using R = long double; geometry::point<R> a, b, c; std::cin >> a >> b >> c; geometry::circle<R> cir = geometry::circumscribed_circle(a, b, c); std::cout << cir.o.x() << " " << cir.o.y() << " " << cir.r << std::endl; }