正文
增加 8 行删除 2 行
211 行未改动全部展开212213214215216217218219220288 行未改动全部展开509510511512513514515516517271 行未改动全部展开789790791792793794795796129 行未改动全部展开926927928929930931932933145 行未改动全部展开211 行未改动全部展开Fixed("2").qpow(10); // 1024BigInt("2").qpow(100); // 2^100```指数非负,否则抛 `runtime_error`。**复杂度 $O(\log b \cdot M(N)$**。### 5.2 绝对值:`abs()`**复杂度 $O(N)$**。288 行未改动全部展开| 构造放大整数 | `Fixed::fromIntExp(1LL, 100)` | ^ || 构造科学计数法 | `Fixed("1e10")` |^|| 加法/减法 | `a + b`、`a - b` | ^ || 乘法 | `a * b` | $O(M(N))$ || 整数在左的运算 | `5 - x`、`5 / x` | **暂不支持** || 除法 | `a / b`、`a.divide(b, k)` | $O(M(N)\log N)$ || 带余除法 | `a.div_mod(b)` | ^ || 数学余数 | `a % b` | ^ || 整数余数 | `a % n` | ^ |271 行未改动全部展开Fixed& operator*=(const long long&b){*this=*this*b;return *this;}Fixed& operator*=(const Fixed&b){*this=*this*b;return *this;}Fixed& operator/=(const long long&b){*this=*this/b;return *this;}Fixed& operator/=(const Fixed&b){*this=*this/b;return *this;}Fixed qpow(long long b)const{if(b<0)throw runtime_error("Negative Exp");Fixed ans(1),now=*this;while(b){if(b&1)ans*=now;now*=now;b>>=1;}return ans;}129 行未改动全部展开BigInt& operator%=(const BigInt&b){*this=*this%b;return *this;}BigInt operator/(long long x)const{return BigInt(val/x);}BigInt operator%(long long x)const{return BigInt(val%x);}BigInt& operator/=(long long x){val/=x;return *this;}bool operator==(const BigInt&b)const{return val==b.val;}bool operator!=(const BigInt&b)const{return val!=b.val;}bool operator<(const BigInt&b)const{return val<b.val;}bool operator>(const BigInt&b)const{return val>b.val;}145 行未改动全部展开211 行未改动全部展开212213214215216217218219220288 行未改动全部展开509510511512513514515516517271 行未改动全部展开789790791792793794795796797798799129 行未改动全部展开929930931932933934935936937938939145 行未改动全部展开211 行未改动全部展开Fixed("2").qpow(10); // 1024BigInt("2").qpow(100); // 2^100```指数非负,否则抛 `runtime_error`。**复杂度 $O(\log b \cdot M(N))$**。### 5.2 绝对值:`abs()`**复杂度 $O(N)$**。288 行未改动全部展开| 构造放大整数 | `Fixed::fromIntExp(1LL, 100)` | ^ || 构造科学计数法 | `Fixed("1e10")` |^|| 加法/减法 | `a + b`、`a - b` | ^ || 乘法 | `a * b` | $O(M(N))$ || 整数在左的运算 | `5 - x`、`5 * x` |同对应运算 || 除法 | `a / b`、`a.divide(b, k)` | $O(M(N)\log N)$ || 带余除法 | `a.div_mod(b)` | ^ || 数学余数 | `a % b` | ^ || 整数余数 | `a % n` | ^ |271 行未改动全部展开Fixed& operator*=(const long long&b){*this=*this*b;return *this;}Fixed& operator*=(const Fixed&b){*this=*this*b;return *this;}Fixed& operator/=(const long long&b){*this=*this/b;return *this;}Fixed& operator/=(const Fixed&b){*this=*this/b;return *this;}friend Fixed operator+(long long lhs, const Fixed& rhs) { return Fixed(lhs) + rhs; }friend Fixed operator-(long long lhs, const Fixed& rhs) { return Fixed(lhs) - rhs; }friend Fixed operator*(long long lhs, const Fixed& rhs) { return Fixed(lhs) * rhs; }Fixed qpow(long long b)const{if(b<0)throw runtime_error("Negative Exp");Fixed ans(1),now=*this;while(b){if(b&1)ans*=now;now*=now;b>>=1;}return ans;}129 行未改动全部展开BigInt& operator%=(const BigInt&b){*this=*this%b;return *this;}BigInt operator/(long long x)const{return BigInt(val/x);}BigInt operator%(long long x)const{return BigInt(val%x);}BigInt& operator/=(long long x){val/=x;return *this;}friend BigInt operator+(long long lhs, const BigInt& rhs) { return BigInt(lhs) + rhs; }friend BigInt operator-(long long lhs, const BigInt& rhs) { return BigInt(lhs) - rhs; }friend BigInt operator*(long long lhs, const BigInt& rhs) { return BigInt(lhs) * rhs; }bool operator==(const BigInt&b)const{return val==b.val;}bool operator!=(const BigInt&b)const{return val!=b.val;}bool operator<(const BigInt&b)const{return val<b.val;}bool operator>(const BigInt&b)const{return val>b.val;}145 行未改动全部展开