Skip to content

improve/fix numbers #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions number/dual_number.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <type_traits>

namespace dual_number_ {
Expand Down
7 changes: 6 additions & 1 deletion number/min_max_semiring.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include <limits>

// min-max 半環(加法が min, 乗法が max, 零元が INF, 単位元が -INF)
// Verified: abc236g
// Verified: abc236g, abc388f
template <class T> struct min_max_semiring {
T val;
min_max_semiring() : val(std::numeric_limits<T>::max()) {
Expand All @@ -21,6 +22,10 @@ template <class T> struct min_max_semiring {
min_max_semiring &operator*=(const min_max_semiring &r) { return *this = *this * r; }
bool operator==(const min_max_semiring &r) const { return this->val == r.val; }
bool operator!=(const min_max_semiring &r) const { return !(*this == r); }
bool operator<(const min_max_semiring &r) const { return this->val < r.val; }
bool operator>(const min_max_semiring &r) const { return this->val > r.val; }
bool operator<=(const min_max_semiring &r) const { return this->val <= r.val; }
bool operator>=(const min_max_semiring &r) const { return this->val >= r.val; }
template <class OStream> friend OStream &operator<<(OStream &os, const min_max_semiring &x) {
return os << x.val;
}
Expand Down
4 changes: 3 additions & 1 deletion number/modint_mersenne61.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class ModIntMersenne61 {

ModIntMersenne61() : _v(0) {}
// 0 <= x < md * 2
explicit ModIntMersenne61(long long x) : _v(x >= md ? x - md : x) {}
explicit ModIntMersenne61(long long x) : _v(x >= md ? x - md : x) {
assert(0 <= x and x < md * 2);
}

long long val() const noexcept { return _v; }

Expand Down