#include "num.h" Num::Num(int value, int modulo) { this->value = value % modulo; this->modulo = modulo; } Num& Num::operator=(const Num& other) { this->value = other.value; this->modulo = other.modulo; return *this; } Num Num::operator+(const Num& other) { long long buffer = this->value; buffer += other.value; return Num(buffer % this->modulo, this->modulo); } Num Num::operator-(const Num& other) { long long buffer = this->value; buffer -= other.value; while (buffer < 0) { buffer += this->modulo; } return Num(buffer, this->modulo); } Num Num::operator*(const Num& other) { long long buffer = this->value; buffer *= other.value; return Num(buffer % this->modulo, this->modulo); } Num Num::operator+(int num) { long long buffer = this->value; buffer += num; return Num(buffer % this->modulo, this->modulo); } Num Num::operator-(int num) { long long buffer = this->value; buffer -= num; while (buffer < 0) { buffer += this->modulo; } return Num(buffer, this->modulo); } Num Num::operator*(int num) { long long buffer = this->value; buffer *= num; return Num(buffer % this->modulo, this->modulo); } Num& Num::operator+=(const Num& other) { long long buffer = this->value; buffer += other.value; this->value = buffer % this->modulo; return *this; } Num& Num::operator-=(const Num& other) { long long buffer = this->value; buffer -= other.value; while (buffer < 0) { buffer += this->modulo; } this->value = buffer; return *this; } Num& Num::operator*=(const Num& other) { long long buffer = this->value; buffer *= other.value; this->value = buffer % this->modulo; return *this; } Num& Num::operator+=(int _num) { long long buffer = this->value; buffer += _num; this->value = buffer % this->modulo; return *this; } Num& Num::operator-=(int _num) { long long buffer = this->value; buffer -= _num; while (buffer < 0) { buffer += this->modulo; } this->value = buffer; return *this; } Num& Num::operator*=(int _num) { long long buffer = this->value; buffer *= _num; this->value = buffer % this->modulo; return *this; }