原模板是从kuangbin的acm模板里copy过来的,根据博主的代码风格对于模板做了一些写法上的小调整,不过呢~
因为博主本人有强迫症(ACMer通病)~~~所以经过一个下午+晚上的修改,将原来只支持无符号大整数的运算改成了支持有符号大整数的运算~~乘法除法挺好修改的,对于新的加法减法写了两个只支持无符号大数的加减法,根据运算符两边的符号位决定运算方式~~~顺便加上了大整数之间的除法运算和几个比较运算符~
模板检查了些许遍,应该没有啥bug了,除了输入-0(本来就不应该吗~)~~~~(有发现的童鞋一定要戳我~~~)
检验状况:
附上模板吧
//Copy from kuangbin~,modify by Siryuanshao
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>
#define MAXN 999999999
#define MAXSIZE 5000
#define DLEN 9
using namespace std;
class BigInt
{
private:
int a[500];
int len;
bool sign;
//sign表示符号位的正负~
protected:
BigInt add(const BigInt&,const bool)const;
BigInt subtract(const BigInt&,const bool)const;
//两个无符号整形的加减法,flag标明结果的符号位~~
public:
BigInt() {sign=false;len=1;memset(a,0,sizeof(a));}
BigInt(const int);
BigInt(const char*);
BigInt(const BigInt&);
BigInt& operator=(const BigInt&);
friend istream& operator>>(istream&,BigInt&);
friend ostream& operator<<(ostream&,const BigInt&);
friend BigInt abs(const BigInt&);
BigInt operator+(const BigInt&)const;
BigInt operator-(const BigInt&)const;
BigInt operator*(cons