This documentation is automatically generated by online-judge-tools/verification-helper
#include <cassert>
#include "../ntimes_centroid.hpp"
int main() {
using intgeometry2d::i32;
using LP32 = intgeometry2d::lattice_point<i32>;
using intgeometry2d::lattice_points;
using intgeometry2d::ntimes_centroid;
lattice_points<i32> pts({
LP32(1, 5),
LP32(4, 8),
LP32(-5, 0),
LP32(-8, -9)
});
assert(ntimes_centroid(pts) == LP32(-8, 4));
}
#line 1 "src/integer-geometry/unit-test/unit-test-ntimes_centroid.cpp"
#include <cassert>
#line 2 "src/integer-geometry/ntimes_centroid.hpp"
#include <numeric>
#line 2 "src/integer-geometry/point.hpp"
#line 2 "src/integer-geometry/alias.hpp"
#include <cstddef>
#include <cstdint>
namespace intgeometry2d {
using isize = std::ptrdiff_t;
using usize = std::size_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
} // intgeometry2d
#line 4 "src/integer-geometry/point.hpp"
namespace intgeometry2d {
template< typename Z >
class lattice_point {
Z x_, y_;
public:
lattice_point() {}
lattice_point(Z x_, Z y_) : x_(x_), y_(y_) {}
Z x() const { return x_; }
Z y() const { return y_; }
bool operator==(const lattice_point &p) const { return x_ == p.x_ and y_ == p.y_; }
bool operator!=(const lattice_point &p) const { return x_ != p.x_ or y_ != p.y_; }
lattice_point operator+(lattice_point p) { return lattice_point(x_ + p.x_, y_ + p.y_); }
lattice_point operator-(lattice_point p) { return lattice_point(x_ - p.x_, y_ - p.y_); }
Z norm() const { return x_ * x_ + y_ * y_; }
};
} // intgeometry2d
#line 2 "src/integer-geometry/points.hpp"
#include <vector>
#line 6 "src/integer-geometry/points.hpp"
namespace intgeometry2d {
template< typename Z >
using lattice_points = std::vector< lattice_point<Z> >;
} // intgeometry2d
#line 7 "src/integer-geometry/ntimes_centroid.hpp"
namespace intgeometry2d {
template< typename Z >
lattice_point< Z > ntimes_centroid(const lattice_points<Z> &pts) {
return std::accumulate(pts.begin(), pts.end(), lattice_point<Z>(0, 0));
}
} // intgeometry2d
#line 4 "src/integer-geometry/unit-test/unit-test-ntimes_centroid.cpp"
int main() {
using intgeometry2d::i32;
using LP32 = intgeometry2d::lattice_point<i32>;
using intgeometry2d::lattice_points;
using intgeometry2d::ntimes_centroid;
lattice_points<i32> pts({
LP32(1, 5),
LP32(4, 8),
LP32(-5, 0),
LP32(-8, -9)
});
assert(ntimes_centroid(pts) == LP32(-8, 4));
}