library

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

View the Project on GitHub maspypy/library

:warning: alg/monoid/lcm.hpp

Code

// 大きいときは infty<T>
template <typename T>
struct Monoid_Lcm {
  using value_type = T;
  using X = value_type;
  static X op(X x, X y) {
    if (x == infty<T> || y == infty<T>) return infty<T>;
    x /= gcd(x, y);
    if (x >= ceil(infty<T>, y)) return infty<T>;
    return x * y;
  }
  static constexpr X unit() { return 1; }
  static constexpr bool commute = 1;
};
#line 1 "alg/monoid/lcm.hpp"

// 大きいときは infty<T>
template <typename T>
struct Monoid_Lcm {
  using value_type = T;
  using X = value_type;
  static X op(X x, X y) {
    if (x == infty<T> || y == infty<T>) return infty<T>;
    x /= gcd(x, y);
    if (x >= ceil(infty<T>, y)) return infty<T>;
    return x * y;
  }
  static constexpr X unit() { return 1; }
  static constexpr bool commute = 1;
};
Back to top page