#pragma once
#include "../../../util/util/lib.hpp"
namespace tifa_libs {
template <std::floating_point T>
CEXP T gcd_fp(T a, T b, T eps = 1e-2) NE {
if ((a = abs(a)) < (b = abs(b))) swap(a, b);
while (a - b > eps) {
if (b < eps) return a;
swap(a = std::fmod(a, b), b);
}
return a;
}
} // namespace tifa_libs
#line 2 "src/nt/gl/gcd_fp/lib.hpp"
#line 2 "src/util/util/lib.hpp"
// https://github.com/Tiphereth-A/CP-lib
#include <bits/extc++.h>
// clang-format off
namespace tifa_libs {
#define CEXP constexpr
#define CEXPE constexpr explicit
#define CR const&
#define CP const*
#define PC *const
#define CPC const*const
#define TPN typename
#define NE noexcept
#define CNE const noexcept
#define ND [[nodiscard]]
#define cT_(...) std::conditional_t<sizeof(__VA_ARGS__) <= sizeof(size_t) * 2, __VA_ARGS__, __VA_ARGS__ CR>
// NOLINTNEXTLINE(misc-const-correctness)
#define flt_(T, i, l, r, ...) for (T i = (l), i##e = (r)__VA_OPT__(, ) __VA_ARGS__; i < i##e; ++i)
#define retif_(cond, if_true, ...) if cond return if_true __VA_OPT__(; else return __VA_ARGS__)
#ifdef ONLINE_JUDGE
#undef assert
#define assert(x) 42
#endif
using namespace std::ranges;
using namespace std::literals;
template <class T>
CEXP T abs(T x) NE { retif_((x < 0), -x, x); }
} // namespace tifa_libs
// clang-format on
#line 4 "src/nt/gl/gcd_fp/lib.hpp"
namespace tifa_libs {
template <std::floating_point T>
CEXP T gcd_fp(T a, T b, T eps = 1e-2) NE {
if ((a = abs(a)) < (b = abs(b))) swap(a, b);
while (a - b > eps) {
if (b < eps) return a;
swap(a = std::fmod(a, b), b);
}
return a;
}
} // namespace tifa_libs