#include #include "num.h" inline Num::Num(int value, int modulo) : value(value), modulo(modulo) { if (modulo != 0) { this->value = value % modulo; } } inline Num& Num::operator=(const Num& other) { return *this; } inline Num Num::operator+(const Num& other) { return Num(this->value + other.value, modulo); } inline Num Num::operator-(const Num& other) { return Num(this->value - other.value, modulo); } inline Num Num::operator*(const Num& other) { return Num(this->value * other.value, modulo); } inline Num Num::operator+(int num) { this->value = value + num; return *this; } inline Num Num::operator-(int num) { this->value = value - num; return *this; } inline Num Num::operator*(int num) { this->value = value * num; return *this; } inline Num& Num::operator+=(const Num& other) { this->value = (value + other.value) % modulo; return *this; } inline Num& Num::operator-=(const Num& other) { if (value - other.value < 0) { this->value = value - other.value + modulo; } else { this->value = value - other.value; } return *this; } inline Num& Num::operator*=(const Num& other) { this->value = (value * other.value) % modulo; return *this; } inline Num& Num::operator+=(int num) { this->value = (value + num % modulo) % modulo; return *this; } inline Num& Num::operator-=(int num) { if (value - num % modulo < 0) { this->value = value - num % modulo + modulo; } else { this->value = value - num % modulo; } return *this; } inline Num& Num::operator*=(int num) { int64_t a, b; a = static_cast(value); b = static_cast(num); this->value = (a * b % modulo) % modulo; return *this; }