This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub luzhiled1333/comp-library
// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A #include "src/geometry/R2/class/point.hpp" #include "src/geometry/R2/class/vector.hpp" #include <iostream> namespace luz { void main_() { using R = double; using Vector = R2::Vector< R >; Vector a(3.0, 2.5); a += 3 * (Vector(2.0, 2.5) + Vector(-3.0, 2.0)) * 2; a -= (Vector(4.0, 1.5) - Vector(-8.0, 1.0)) / 3; a *= 3; a /= 2; using Point = R2::Point< R >; Point b(3.0, 2.5); b += 3 * (Point(2.0, 2.5) + Point(-3.0, 2.0)) * 2; b -= (Point(4.0, 1.5) - Point(-8.0, 1.0)) / 3; b *= 3; b /= 2; a += Point(Point(1.0, 0.0) + Vector(0.0, 1.0)); b += Vector(Vector(1.0, 0.0) + Point(0.0, 1.0)); std::cout << "Hello World" << std::endl; } } // namespace luz int main() { luz::main_(); }
#line 1 "unit-test/geometry/R2/class/vector-and-point.test.cpp" // verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A #line 2 "src/geometry/R2/class/point.hpp" #line 2 "src/geometry/R2/class/vector.hpp" #line 2 "src/geometry/R2/utility/equals.hpp" #line 2 "src/geometry/R2/numbers/sign.hpp" #line 2 "src/cpp-template/header/int-alias.hpp" #include <cstdint> namespace luz { using i32 = std::int32_t; using i64 = std::int64_t; using i128 = __int128_t; using u32 = std::uint32_t; using u64 = std::uint64_t; using u128 = __uint128_t; } // namespace luz #line 4 "src/geometry/R2/numbers/sign.hpp" namespace luz::numbers::sign { constexpr i32 negative = -1; constexpr i32 zero = 0; constexpr i32 positive = +1; } // namespace luz::numbers::sign #line 2 "src/geometry/R2/utility/sign.hpp" #line 2 "src/geometry/R2/numbers/eps.hpp" #include <cmath> namespace luz::R2 { long double &eps() { static long double EPS = 1e-10; return EPS; } void set_eps(long double EPS) { eps() = EPS; } } // namespace luz::R2 #line 6 "src/geometry/R2/utility/sign.hpp" namespace luz::R2 { template < typename R > i32 sign(R r) { if (r < -eps()) return numbers::sign::negative; if (r > +eps()) return numbers::sign::positive; return numbers::sign::zero; } } // namespace luz::R2 #line 5 "src/geometry/R2/utility/equals.hpp" namespace luz::R2 { template < typename R > bool equals(R r0, R r1) { return sign(r1 - r0) == numbers::sign::zero; } } // namespace luz::R2 #line 2 "src/geometry/R2/utility/is-fp-exception.hpp" #line 4 "src/geometry/R2/utility/is-fp-exception.hpp" namespace luz::R2 { template < typename R > bool is_fp_exception(R r) { return std::isinf(r) or std::isnan(r); } } // namespace luz::R2 #line 5 "src/geometry/R2/class/vector.hpp" #include <cassert> #include <vector> namespace luz::R2 { template < typename R > class Vector { R x_, y_; public: Vector(): x_(0), y_(0) {} Vector(R x, R y): x_(x), y_(y) { assert(not is_fp_exception(x_) and not is_fp_exception(y_)); } R x() const { return x_; } R y() const { return y_; } friend bool equals(const Vector &v0, const Vector &v1) { return equals(v0.x(), v1.x()) and equals(v0.y(), v1.y()); } Vector &operator+=(const Vector &v) { x_ += v.x_; y_ += v.y_; return *this; } Vector &operator-=(const Vector &v) { x_ -= v.x_; y_ -= v.y_; return *this; } Vector operator+(const Vector &v) const { return Vector(*this) += v; } Vector operator-(const Vector &v) const { return Vector(*this) -= v; } Vector operator+() const { return *this; } Vector operator-() const { return Vector() - *this; } Vector &operator*=(const R r) { x_ *= r; y_ *= r; return *this; } Vector &operator/=(const R r) { x_ /= r; y_ /= r; return *this; } Vector operator*(const R r) const { return Vector(*this) *= r; } Vector operator/(const R r) const { return Vector(*this) /= r; } friend Vector operator*(const R r, const Vector &v) { return Vector(v) *= r; } }; template < typename R > using Vectors = std::vector< Vector< R > >; } // namespace luz::R2 #line 4 "src/geometry/R2/class/point.hpp" #line 6 "src/geometry/R2/class/point.hpp" namespace luz::R2 { template < typename R > using Point = Vector< R >; template < typename R > using Points = std::vector< Point< R > >; } // namespace luz::R2 #line 5 "unit-test/geometry/R2/class/vector-and-point.test.cpp" #include <iostream> namespace luz { void main_() { using R = double; using Vector = R2::Vector< R >; Vector a(3.0, 2.5); a += 3 * (Vector(2.0, 2.5) + Vector(-3.0, 2.0)) * 2; a -= (Vector(4.0, 1.5) - Vector(-8.0, 1.0)) / 3; a *= 3; a /= 2; using Point = R2::Point< R >; Point b(3.0, 2.5); b += 3 * (Point(2.0, 2.5) + Point(-3.0, 2.0)) * 2; b -= (Point(4.0, 1.5) - Point(-8.0, 1.0)) / 3; b *= 3; b /= 2; a += Point(Point(1.0, 0.0) + Vector(0.0, 1.0)); b += Vector(Vector(1.0, 0.0) + Point(0.0, 1.0)); std::cout << "Hello World" << std::endl; } } // namespace luz int main() { luz::main_(); }