#include "num.h" #include Num::Num(int value_, int modulo_) { value = value_ % modulo_; modulo = modulo_; } Num &Num::operator=(const Num& other) { value = other.value; return *this; } Num Num::operator+(const Num& other) { return Num(value + other.value, modulo); } Num Num::operator-(const Num& other) { return Num(value - other.value, modulo); } Num Num::operator*(const Num& other) { return Num(value * other.value, modulo); } Num Num::operator+(int num) { value += num; value %= modulo; return Num(value, modulo); } Num Num::operator-(int num) { value -= num; value %= modulo; return Num(value, modulo); } Num Num::operator*(int num) { value *= num; value %= modulo; return Num(value, modulo); } Num& Num::operator+=(const Num& other) { value += other.value; value %= modulo; return *this; } Num& Num::operator-=(const Num& other) { value -= other.value; if (value < 0) value = value - floor(static_cast(value) / modulo) * modulo; else value %= modulo; return *this; } Num& Num::operator*=(const Num& other) { value *= other.value; value %= modulo; return *this; } Num& Num::operator+=(int num) { int64_t qwerty = static_cast(value); qwerty += num; qwerty %= modulo; value = qwerty; return *this; } Num& Num::operator-=(int num) { value -= num; if (value < 0) value = value - floor(static_cast(value) / modulo) * modulo; else value %= modulo; return *this; } Num& Num::operator*=(int num) { int64_t qwerty = static_cast(value); qwerty *= num; qwerty %= modulo; value = qwerty; return *this; }