c++ 无符号bigint高精度大整数
此代码除了减法和乘法以外均参考了刘汝佳的《算法竞赛入门经典第二版》,亲测DevC++可以编译通过。代码在codevs( codevs.cn )上通过高精度全部题目。POWERED BY PHANTOM 大神勿喷,希望大家支持!
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
struct bigint{ // only positive number;
static const int BASE=100000000;
static const int WIDTH=8;
vector<int> s;
//value
bigint(long long num=0){ *this = num;}
bigint operator = (long long num){
s.clear();
do{
s.push_back(num%BASE);
num/=BASE;
}while(num>0);
return *this;
}
bigint operator = (const string& str){
s.clear() ;
int x,len = (str.length()-1)/WIDTH + 1;
for(int i=0;i<len;i++){
int end = str.length() - i*WIDTH;
int star