Fu_L's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Fu-L/cp-library

:heavy_check_mark: template
(src/geometry/template.hpp)

幾何テンプレートです.

Real, EPS, PI

Reallong double のエイリアスです.
必要となる精度や速度次第で double に変えて使うこともできます.

EPS は $10^{-8}$ を表す Real 型の値です.
問題に応じて調整してください.

PI は円周率を表す Real 型の値です.

sign

int sign(Real x)

$x$ の符号を返します.
ただし, $\mathrm{-EPS} \leq x \leq \mathrm{EPS}$ のときに $0$ と判定します.

eq

bool eq(Real a, Real b)

$a = b$ であるか判定します.
ただし, $|a - b| \leq \mathrm{EPS}$ であるときに等しいと判定します.

Depends on

Required by

Verified with

Code

#pragma once
#include "../template/template.hpp"
using Real = long double;
constexpr Real EPS = Real(1e-8), PI = 3.141592653589793238462643383279L;
int sign(const Real& r) {
    if(r <= -EPS) return -1;
    if(r >= +EPS) return +1;
    return 0;
}
bool eq(const Real& a, const Real& b) {
    return sign(a - b) == 0;
}
#line 2 "src/template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
#line 3 "src/geometry/template.hpp"
using Real = long double;
constexpr Real EPS = Real(1e-8), PI = 3.141592653589793238462643383279L;
int sign(const Real& r) {
    if(r <= -EPS) return -1;
    if(r >= +EPS) return +1;
    return 0;
}
bool eq(const Real& a, const Real& b) {
    return sign(a - b) == 0;
}
Back to top page