```
#include <iostream>
#include <bitset>
using namespace std;
class _LL {
protected:
bool op;
bitset<63> t;
public:
_LL() {
op = 0;
t.set();
}
friend istream& operator>> (istream& in, _LL& T);
friend ostream& operator<< (ostream& out, _LL& T);
long long to_ll() {
long long _ans = 0;
for (long long i = 0; i < 63; ++i) _ans |= t[i] << (62 - i);
if (op) _ans = ~_ans;
return _ans;
}
long long operator = (long long _ll) {
long long _cnt = _ll;
op = 0, t.set();
if (_ll < 0) _ll = ~_ll, op = 1;
for (int i = 0; i < 63; ++i) t[i] = (_ll >> (62 - i) & 1);
if (op) t.flip();
return _cnt;
}
long long operator + (long long _and) {
return to_ll() + _and;
}
long long operator - (long long _sub) {
return to_ll() - _sub;
}
long long operator += (long long _and) {
long long _ll = to_ll() + _and;
op = 0;
operator = (_ll);
return _ll;
}
long long operator -= (long long _sub) {
operator = (operator - (_sub));
return to_ll();
}
};
istream& operator>> (istream& in, _LL& T) {
long long _ll;
in >> _ll;
T = _ll;
return in;
}
ostream& operator<< (ostream& out, _LL& T) {
out << T.to_ll() << ' ';
return out;
}
_LL T;
int main()
{
return 0;
}
```
汪思源在2025-11-19 22:00:47追加了内容
#include <iostream>
#include <bitset>
#define N 1048576
using namespace std;
namespace std {
class ll {
protected:
bitset<64> t;
public:
ll() {
t.reset();
}
friend istream& operator>> (istream& in, ll& T);
friend ostream& operator<< (ostream& out, ll& T);
long long to_ll() {
long long _ans = 0;
for (long long i = 1; i < 64; ++i) _ans |= t[i] << (63 - i);
if (t[0]) _ans = ~_ans;
return _ans;
}
long long operator = (long long _ll) {
long long _cnt = _ll;
t[0] = 0, t.reset();
if (_ll < 0) _ll = ~_ll, t[0] = 1;
for (int i = 1; i < 64; ++i) t[i] = (_ll >> (63 - i)) & 1;
if (t[0]) t.flip(), t[0].flip();
return _cnt;
}
long long operator + (long long _and) {
return to_ll() + _and;
}
long long operator - (long long _sub) {
return to_ll() - _sub;
}
long long operator += (long long _and) {
operator = (operator + (_and));
return to_ll();
}
long long operator -= (long long _sub) {
operator = (operator - (_sub));
return to_ll();
}
};
istream& operator>> (istream& in, ll& T) {
long long _ll;
in >> _ll;
T = _ll;
return in;
}
ostream& operator<< (ostream& out, ll& T) {
out << T.to_ll() << ' ';
return out;
}
}
汪思源在2025-11-21 23:29:31追加了内容
#include <iostream>
#include <bitset>
#include <map>
#define N 1048576
namespace std {
std::map<string, int> b;
std::bitset<N> t;
int cnt = 0;
class Int{
protected:
int _pos;
int _size;
public:
Int(int size = 32) : _pos(cnt), _size(size){
cnt += _size;
}
friend istream& operator>> (istream& in, Int& T);
friend ostream& operator<< (ostream& out, Int& T);
long long to_ll() {
long long _ans = 0;
for (long long i = 1; i < _size; ++i) _ans |= (t[i + _pos] ^ t[_pos]) << (_size - i - 1);
if (t[_pos]) _ans = ~_ans;
return _ans;
}
long long operator = (long long _ll) {
long long _cnt = _ll;
t[_pos] = 0;
if (_ll < 0) _ll = ~_ll, t[_pos] = 1;
for (int i = 1; i < _size; ++i) t[i + _pos] = ((_ll >> (_size - i - 1)) & 1) ^ t[_pos];
return _cnt;
}
long long operator + (long long _and) {
return to_ll() + _and;
}
long long operator - (long long _sub) {
return to_ll() - _sub;
}
long long operator * (long long _mul) {
return to_ll() * _mul;
}
long long operator / (long long _div) {
return to_ll() / _div;
}
long long operator += (long long _and) {
operator = (operator + (_and));
return to_ll();
}
long long operator -= (long long _sub) {
operator = (operator - (_sub));
return to_ll();
}
long long operator *= (long long _mul) {
operator = (operator * (_mul));
return to_ll();
}
long long operator /= (long long _div) {
operator = (operator / (_div));
return to_ll();
}
};
istream& operator>> (istream& in, Int& T) {
long long _ll;
in >> _ll;
T = _ll;
return in;
}
ostream& operator<< (ostream& out, Int& T) {
out << T.to_ll() << ' ';
return out;
}
class Bool{
protected:
int _pos;
public:
Bool() : _pos(cnt) {
++cnt;
}
friend istream& operator>> (istream& in, Bool& T);
friend ostream& operator<< (ostream& out, Bool& T);
long long to_bool() {
return t[_pos];
}
bool operator = (bool _bool) {
return t[_pos] = _bool;
}
bool operator & (bool _And) {
return t[_pos] & _And;
}
bool operator ^ (long long _xor) {
return t[_pos] ^ _xor;
}
bool operator | (long long _or) {
return t[_pos] | _or;
}
bool operator &= (long long _And) {
operator = (operator & (_And));
return t[_pos];
}
bool operator ^= (long long _xor) {
operator = (operator ^ (_xor));
return t[_pos];
}
bool operator |= (long long _or) {
operator = (operator | (_or));
return t[_pos];
}
};
istream& operator>> (istream& in, Bool& T) {
bool _ll;
in >> _ll;
T = _ll;
return in;
}
ostream& operator<< (ostream& out, Bool& T) {
out << T.to_bool() << ' ';
return out;
}
}
汪思源在2025-11-28 22:32:54追加了内容
#include <iostream>
#include <climits>
#include <cstddef>
#include <bitset>
#include <map>
#define N 1048576
namespace Std {
typedef unsigned long long ull;
typedef long long ll;
std::bitset<N> t;
int cnt = 0;
class SignedInt{
protected:
int _pos;
int _size;
public:
SignedInt& operator = (const SignedInt& other) {
for (int i = 0; i < _size && i < other._size; ++i) t[_pos + i] = t[other._pos + i];
return *this;
}
SignedInt& operator = (SignedInt&& other) noexcept {
if (this == &other) return other;
_pos = other._pos;
_size = other._size;
other._pos = -1;
other._size = 0;
return *this;
}
SignedInt& operator = (ll _ll) {
if (_ll < 0) t[_pos] = 1, _ll = ~_ll;
for (int i = 1; i < _size; ++i) t[_pos + i] = (_ll >> (_size - i - 1) & 1) ^ t[_pos];
return *this;
}
SignedInt(const SignedInt& other) : _pos(cnt), _size(other._size) {
cnt += _size;
*this = other;
}
SignedInt(SignedInt&& other) noexcept : _pos(other._pos), _size(other._size){
other._pos = -1;
other._size = 0;
}
SignedInt(ll _ll) : _pos(cnt), _size(64) {
cnt += _size;
*this = _ll;
}
SignedInt(int __size, ll _ll) : _pos(cnt), _size(__size) {
cnt += _size;
*this = _ll;
}
SignedInt() : _pos(cnt), _size(64) {
cnt += _size;
*this = 0;
}
~SignedInt() = default;
friend std::istream& operator>> (std::istream& in, SignedInt& T);
friend std::ostream& operator<< (std::ostream& out, SignedInt& T);
operator ll() {
ll _ans = 0;
for (ll i = 0; i < _size; ++i) _ans |= (t[i + _pos] ^ t[_pos]) << (_size - i - 1);
if (t[_pos]) _ans = ~_ans;
return _ans;
}
};
std::istream& operator>> (std::istream& in, SignedInt& T) {
ll _ll;
in >> _ll;
T = _ll;
return in;
}
std::ostream& operator<< (std::ostream& out, SignedInt& T) {
out << (ll)T << ' ';
return out;
}
class UnsignedInt{
protected:
int _pos;
int _size;
public:
UnsignedInt& operator = (const UnsignedInt& other) {
for (int i = 0; i < _size && i < other._size; ++i) t[_pos + i] = t[other._pos + i];
return *this;
}
UnsignedInt& operator = (UnsignedInt&& other) noexcept {
if (this == &other) return other;
_pos = other._pos;
_size = other._size;
other._pos = -1;
other._size = 0;
return *this;
}
UnsignedInt& operator = (ull _ull) {
for (int i = 0; i < _size; ++i) t[_pos + i] = (_ull >> (_size - i) & 1);
return *this;
}
UnsignedInt(const UnsignedInt& other) : _pos(cnt), _size(other._size) {
cnt += _size;
*this = other;
}
UnsignedInt(UnsignedInt&& other) noexcept : _pos(other._pos), _size(other._size){
other._pos = -1;
other._size = 0;
}
UnsignedInt(ull _ull) : _pos(cnt), _size(64) {
cnt += _size;
*this = _ull;
}
UnsignedInt(int __size, ull _ull) : _pos(cnt), _size(__size) {
cnt += _size;
*this = _ull;
}
UnsignedInt() : _pos(cnt), _size(64) {
cnt += _size;
*this = 0;
}
~UnsignedInt() = default;
friend std::istream& operator>> (std::istream& in, UnsignedInt& T);
friend std::ostream& operator<< (std::ostream& out, UnsignedInt& T);
operator ull() {
ull _ans = 0;
for (int i = 0; i < _size; ++i) _ans |= t[i + _pos] << (_size - i);
return _ans;
}
};
std::istream& operator>> (std::istream& in, UnsignedInt& T) {
ull _ll;
in >> _ll;
T = _ll;
return in;
}
std::ostream& operator<< (std::ostream& out, UnsignedInt& T) {
out << (ull)T << ' ';
return out;
}
class Bool{
protected:
int _pos;
public:
Bool(bool _bool = false) : _pos(cnt) {
++cnt, t[_pos] = _bool;
}
Bool(const Bool& other) : _pos(cnt) {
++cnt, t[_pos] = t[other._pos];
}
Bool(Bool&& other) noexcept : _pos(other._pos) {
other._pos = -1;
}
Bool& operator = (const Bool& other) {
return *this = other;
}
Bool& operator = (Bool&& other) noexcept {
return *this = other;
}
Bool& operator = (bool _bool) {
return *this = _bool;
}
friend std::istream& operator>> (std::istream& in, Bool& T);
friend std::ostream& operator<< (std::ostream& out, Bool& T);
operator bool() const {
return t[_pos];
}
};
std::istream& operator>> (std::istream& in, Bool& T) {
bool _bool;
in >> _bool;
T = _bool;
return in;
}
std::ostream& operator<< (std::ostream& out, Bool& T) {
out << (bool)T << ' ';
return out;
}
}
后续可能添加高精度

