亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 高精度庫.cpp

?? 西電內部用的高精度庫,原是保密的!!!我奉獻了出來
?? CPP
字號:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

int const MAX = 300;
class BigInt
{
public:
	int data[MAX]; //用于存放該萬進制數
	int num;  //該數有多少位
	bool neg;  //是否負數

public:
	void assign(const string &s); //f1: 用string型給BigInt賦值
	void assign(int n); //f2: 用int型給BigInt賦值

	//f3: 輸出BigInt值,副作用輸出該BigInt的輸出流被setfill('0')
	friend ostream & operator << (ostream & outf, const BigInt &a);

	BigInt(BigInt &b); //f4: 拷貝構造函數,可以用'='給BigInt賦BigInt值,需要加上上面的構造函數
	BigInt(int a = 0){assign(a);} //f5: 構造函數

	void operator -() {if(!this->is_zero()) neg = !neg;} //f6: 對該對象取負
	bool is_zero() {return data[num - 1] == 0;} //f7: 判斷是否為0


	void operator +=  (BigInt &a); //f11: 給當前BigInt 加上一個BigInt
	void operator +=  (int a){BigInt temp(a); *this += temp;} //f12: 給當前BigInt 加上一個int
	BigInt operator + (BigInt &a) {BigInt temp = *this; temp += a; return temp;} //f13: 兩個BigInt相加
	BigInt operator + (int a) {BigInt temp = *this; temp +=a; return temp;} //f14: BigInt與int相加 

	void operator -=  (BigInt &a) {neg = !neg; *this += a; neg = !neg;}//f15: 給當前BigInt減去一個BigInt
	void operator -=  (int a) {BigInt temp(a); *this -= temp;} //f16: 給當前BigInt減去一個int
	BigInt operator - (BigInt &a) {BigInt temp = *this; temp -= a; return temp;} //f17: 兩個BigInt相減
	BigInt operator - (int a) {BigInt temp = *this; temp -= a; return temp;} //f18: BigInt與int相加

	bool operator  >  (BigInt &a) {int i = Less(this, &a); return i == -1;} //f20: 判斷a是否大于b
	bool operator  >= (BigInt &a) {int i = Less(this, &a); return i != 1;} //f21: 判斷a是否大于等于b
	bool operator  <  (BigInt &a) {int i = Less(this, &a); return i == 1;} //f22: 判斷a是否小于b
	bool operator  <= (BigInt &a) {int i = Less(this, &a); return i != -1;} //f23: 判斷a是否小于等于b
	bool operator  == (BigInt &a) {int i = Less(this, &a); return i == 0;} //f24: 判斷a是否等于b
	bool operator  != (BigInt &a) {int i = Less(this, &a); return i != 0;} //f25: 判斷a是否不等于b

	void operator *=  (int a) {Positive_mul(this, abs(a)); neg = neg != a<0; if(a == 0) neg = false;} //f28: 給當前BigInt乘以int a
	//f29: 給當前BigInt乘以Bigint a
	void operator *=  (BigInt & a) 	{Positive_mul(this, &a); neg = neg != a.neg; if(a.is_zero()) neg = false;} 
	BigInt operator * (int a) {BigInt temp = *this; temp *= a; return temp;} //f30: BigInt乘以int a
	BigInt operator * (BigInt &a) {BigInt temp = *this; temp *= a; return temp;} //f31: BigInt乘以Bigint
	
	void operator /= (int a) {BigInt r, temp(a); div(*this, temp, r);} //f34: BigInt除等于int
	void operator /= (BigInt a) {BigInt r; div(*this, a, r);} //f35: BigInt除等于BigInt
	void operator %= (int a) {BigInt r, temp(a); div(*this, temp, r); *this = r;} //f36: BigInt對int取余
	void operator %= (BigInt a) {BigInt r; div(*this, a, r); *this = r;} //f37: 
	BigInt operator / (int a) {BigInt r,temp = *this, t(a); div(temp, t, r); return temp;} //f38: 
	BigInt operator / (BigInt a) {BigInt r, temp = *this; div(temp, a, r); return temp;} //f39: 
	BigInt operator % (int a) {BigInt r,temp = *this, t(a); div(temp, t, r); return r;} //f40: 
	BigInt operator % (BigInt a) {BigInt r, temp = *this; div(temp, a, r); return r;} //f41: 

	/*******************************************************************************************/
	//f8: 把BigInt b*10000^zero_after_b加到a上
	friend void Positive_add(BigInt *a, BigInt *b, int zero_after_b = 0); 
	friend int Positive_less(BigInt *a, BigInt *b); //f9: 比較兩個BigInt有效位的大小,1:小于,-1:大于,0:等于
	friend void Positive_minus(BigInt *big, BigInt *small); //f10: 對BigInt big減去small,大正數減小正數
	friend int Less(BigInt *a, BigInt *b); //f19: 比較兩個BigInt的大小,1:小于,0:大于,-1:等于
	friend void Positive_mul(BigInt *a, int b); //f26: 非負BigInt乘等于int, 0<=int<10000 
	friend void Positive_mul(BigInt *a, BigInt *b); //f27: 非負BigInt乘等于BigInt
	friend void Positive_div(BigInt &a, BigInt &divisor, BigInt &remainder); //f32: 帶余非負數相除, b != 0
	friend void div(BigInt &a, BigInt &divisor, BigInt &remainder); //f33: BigInt相除
};

/*******************************************************************************************/
/*------------------------------f1: 用string型給BigInt賦值--------------------------------*/
void BigInt::assign(const string &s)
{
	neg = (s[0] == '-');
	num = 0;
	data[0] = 0;
	int j = 0;
	int t = 1;
	for(int i = s.size() - 1; i >= neg; i--)
	{
		j++;
		data[num] += (s[i] - '0') * t;
		t *= 10;
		if(j%4 == 0)
		{
			num++;
			data[num] = 0;
			t = 1;
		}
	}
	if(j%4)
		num++;
}


/*---------------------------f2: 用int型給BigInt賦值--------------------------------------*/
void BigInt::assign(int n)
{
	neg = false;
	if(n < 0)
	{
		neg = true;
		n *= -1;
	}
	num = 0;
	while(n / 10000)
	{
		data[num++] = n % 10000;
		n /= 10000;
	}
	data[num++] = n;
}

/*---------------f3: 輸出BigInt值,副作用輸出該BigInt的輸出流被setfill('0')----------------*/
ostream & operator << (ostream &outf, const BigInt &a)
{
	if(a.neg) 
		outf<<'-';
	int i = a.num - 1;
	outf<<a.data[i];
	outf<<setfill('0');
	while(i > 0)
		outf<<setw(4)<<a.data[--i];
	return outf;
}
/*----------f4: 拷貝構造函數,可以用'='給BigInt賦BigInt值,需要加上上面的構造函數-----------*/
BigInt::BigInt(BigInt &b):neg(b.neg),num(b.num)
{
	for(int i = 0; i < num; i++)
		data[i] = b.data[i];
	//cout<<"Copy constructor Called"<<endl;
}

/*-------------------f8: 把BigInt b*10000^zero_after_b加到a上-------------------*/
void Positive_add(BigInt *a, BigInt *b, int zero_after_b)
{
	if(b->is_zero())
		return;

	//把該數據可能即將用到的數據進行初始化為0
	a->data[a->num] = 0;
	int i, bnum = b->num + zero_after_b;
	for(i = a->num + 1; i < bnum + 1; i++)
		a->data[i] = 0;

	//把b的數據加到該數據上,不進位
	for(i = 0; i < b->num; i++)
		a->data[i + zero_after_b] += b->data[i];

	//控制進位
	int num1 = (bnum > a->num) ? bnum : a->num;
	int teamp = 0; //暫時存放進位
	for(i = 0; i < num1; i++)
	{
		a->data[i] += teamp;
		teamp = a->data[i] / 10000;
		a->data[i] %= 10000;
	}
	if(teamp)
	{
		a->data[a->num] = teamp;
		a->num = num1 + 1;
	}
	else
		a->num = num1;
}

/*------------------------f9: 比較兩個BigInt有效位的大小,1:小于,-1:大于,0:等于-------------------*/
int Positive_less(BigInt *a, BigInt *b)
{
	if(a->num > b->num)
		return -1;
	if(a->num < b->num)
		return 1;
	for(int i = b->num - 1; i >= 0 ; i--)
		if(a->data[i] < b->data[i])
			return 1;
		else if(a->data[i] > b->data[i])
			return -1;
	return 0; //表示等于
}

/*------------------------------f10: 對BigInt big減去small,大正數減小正數-------------------------*/
void Positive_minus(BigInt *big, BigInt *small)
{
	for(int i = 0; i < small->num; i++)
	{
		if(big->data[i] < small->data[i])
		{
			big->data[i + 1] --;
			big->data[i] += 10000;
		}
		big->data[i] -= small->data[i];
	}
	while(!big->data[big->num - 1])
		big->num --;
	if(big->num == 0) big->num = 1;
	if(big->is_zero())
		big->neg = false;
}

/*-------------------------------f11: 給當前BigInt 加上一個BigInt--------------------------------*/
void BigInt::operator +=(BigInt &a)
{
	if(!neg && a.neg)
		if(Positive_less(this, &a) == 1)
		{
			BigInt temp = a;
			Positive_minus(&temp, this);
			*this = temp;
			neg = true;
		}
		else
			Positive_minus(this, &a);
	else if(neg && !a.neg)
	{
		if(Positive_less(this, &a) == 1)
		{
			BigInt temp = a;
			Positive_minus(&temp, this);
			*this = temp;
			neg = false;
		}
		else
		{
			Positive_minus(this, &a);
			neg = true;
		}
	}
	else 
		Positive_add(this, &a); //只加有效位,符號不動
}

/*--------------------------f19: 比較兩個BigInt有效位的大小,1:小于,-1:大于,0:等于------------------------*/
int Less(BigInt *a, BigInt *b)
{
	int i = Positive_less(a, b);
	if(!a->neg && !b->neg)
		return i;
	if(a->neg && b->neg)
		return - i;
	if(a->neg && !b->neg)
		return 1;
	if(!a->neg && b->neg)
		return -1;
}

/*------------------------------f26: BigInt乘等于int, 0<=int<10000 -----------------------------*/
void Positive_mul(BigInt *a, int b)
{
	if(b == 0)
	{
		a->assign(0);
		return;
	}

	//不進位乘法
	for(int i = 0; i < a->num; i++)
		a->data[i] *= b;

	//進位
	int t = 0;
	for(int j = 0; j < a->num; j++)
	{
		a->data[j] += t;
		t = a->data[j] / 10000;
		a->data[j] %= 10000;
	}
	if(t)
		a->data[a->num++] = t;
}

/*----------------------------------f27: 非負BigInt乘等于BigInt----------------------------------*/
void Positive_mul(BigInt *a, BigInt *b)
{
	BigInt result;
	for(int i = 0; i < b->num; i++)
	{
		BigInt temp = *a;
		temp *= b->data[i];
		Positive_add(&result, &temp, i);
	}
	bool boo = a->neg;
	*a = result;
	a->neg = boo;
}

/*---------------------------------f32: 帶余非負數相除, b != 0------------------------------*/
void Positive_div(BigInt &a, BigInt &b, BigInt &r)
{
	//if(b.is_zero()) cout<<"Dived by zero!"<<endl;
	if(a < b){r = a; a.assign(0); return;}//處理特殊情況

	int n = a.num - b.num + 1; //結果的位數,可能多一位

	r.assign(0);
	r.num = b.num - 1;
	for(int i = 0; i < r.num; i++)
		r.data[i] = a.data[n + i];
	if(b.num == 1) //處理b只有一位的特殊情況
		r.num = 1;

	for(int i = n - 1; i >= 0; i--)
	{
		r *= 10000;
		r += a.data[i];
		a.data[i] = 0;
		while(b <= r)
		{
			int header = r.data[r.num - 1];
			if(r.num > b.num)
				header = header * 10000 + r.data[r.num - 2];
			int part_quotient = header/(b.data[b.num - 1] + 1);
			if(part_quotient < 1)
				part_quotient = 1;  //以上6行是“保守試商”的過程

			BigInt temp = b;
			temp *= part_quotient;
			r -= temp;

			a.data[i] += part_quotient;
		}
	}
	a.num = n;
	while(a.data[a.num - 1] == 0)
		a.num --;
}
/*--------------------------------------f33: BigInt相除--------------------------------------------*/
void div(BigInt &a, BigInt &divisor, BigInt &remainder)
{
	bool temp = a.neg != divisor.neg;
	divisor.neg = false;
	a.neg = false;
	Positive_div(a, divisor, remainder);
	if(temp)
	{
		-a;
		-remainder;
	}
}





?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
粉嫩av一区二区三区| 欧美三级一区二区| 久久奇米777| 国精品**一区二区三区在线蜜桃| 欧美一区二区三区在线观看| 日韩av一区二区在线影视| 欧美一级片在线观看| 精品无人码麻豆乱码1区2区 | 丰满岳乱妇一区二区三区| 日本一区二区三区dvd视频在线| 国产成人免费网站| 亚洲乱码一区二区三区在线观看| 欧美日韩中文国产| 精品中文av资源站在线观看| 国产欧美在线观看一区| 99国产精品国产精品久久| 亚洲综合色噜噜狠狠| 日韩一级欧美一级| 国产传媒欧美日韩成人| 亚洲欧美经典视频| 欧美一级免费大片| 成人av网站在线观看免费| 亚洲精品视频观看| 日韩精品资源二区在线| 懂色av一区二区三区免费观看| 亚洲综合在线第一页| 日韩视频免费观看高清在线视频| 懂色av一区二区三区蜜臀| 亚洲激情网站免费观看| 精品第一国产综合精品aⅴ| 91在线云播放| 久久se这里有精品| 亚洲综合激情网| 久久久噜噜噜久久人人看| av爱爱亚洲一区| 麻豆国产精品官网| 一区二区三区.www| 国产情人综合久久777777| 欧美视频中文字幕| 成人精品一区二区三区四区| 午夜免费久久看| 亚洲欧美综合在线精品| 欧美变态tickle挠乳网站| 在线亚洲一区二区| 国产99精品在线观看| 奇米777欧美一区二区| 亚洲色图清纯唯美| 国产日韩欧美一区二区三区乱码 | 亚洲精品日日夜夜| 久久嫩草精品久久久精品一| 欧美日韩亚洲综合在线| av在线这里只有精品| 精品中文av资源站在线观看| 亚洲成人免费在线| 亚洲精品久久久久久国产精华液| 国产亚洲欧美一级| 欧美精品一区二区三区蜜桃视频| 欧美日韩二区三区| 在线亚洲一区二区| 91麻豆精品在线观看| 粉嫩av亚洲一区二区图片| 国产美女一区二区三区| 麻豆精品久久精品色综合| 亚洲国产乱码最新视频| 亚洲免费看黄网站| 亚洲码国产岛国毛片在线| 亚洲日本一区二区| 中文字幕人成不卡一区| 国产精品乱码人人做人人爱| 2021中文字幕一区亚洲| 久久久精品2019中文字幕之3| 精品国产一区二区精华| 日韩欧美国产一区二区在线播放| 91精品黄色片免费大全| 欧美日免费三级在线| 欧美三片在线视频观看| 欧美日韩国产一区| 91精品国产综合久久久蜜臀图片| 欧美日韩国产三级| 91.com在线观看| 欧美大片在线观看一区二区| 日韩精品在线网站| 久久久久久久免费视频了| 国产清纯白嫩初高生在线观看91 | 国产精品毛片高清在线完整版| 久久久久久亚洲综合影院红桃 | 日本美女一区二区三区视频| 日产国产欧美视频一区精品| 蜜桃视频一区二区三区 | 五月天丁香久久| 男男视频亚洲欧美| 国产精品99久| 日本久久电影网| 欧美四级电影网| 精品国产一区二区三区忘忧草 | 91在线小视频| 欧美视频一区二区在线观看| 欧美久久久久久久久| 日韩一卡二卡三卡国产欧美| 日韩欧美色电影| 91麻豆视频网站| 国产成人av电影在线观看| 日本韩国欧美在线| 国产精品你懂的| 久久精品人人做| 国产精品国产三级国产aⅴ原创 | 欧美最猛性xxxxx直播| fc2成人免费人成在线观看播放| 国产成+人+日韩+欧美+亚洲| 国产精品综合网| 91网站最新网址| 三级在线观看一区二区| 久久99久国产精品黄毛片色诱| 国产精品一二三| 色一区在线观看| 精品少妇一区二区三区在线播放 | 国产精品一区2区| 91天堂素人约啪| 日韩一卡二卡三卡四卡| 国产精品久久久久精k8| 美女在线一区二区| www.av精品| 日韩精品一区二区三区swag| ●精品国产综合乱码久久久久| 日产国产高清一区二区三区| 成人精品免费看| 欧美大黄免费观看| 一区二区三区 在线观看视频 | 国产a视频精品免费观看| 欧美日韩综合在线| 国产精品免费人成网站| 日本欧美一区二区| 91免费视频大全| 国产亚洲制服色| 日韩精品福利网| 91高清在线观看| 亚洲欧洲日韩一区二区三区| 蜜桃传媒麻豆第一区在线观看| 91小宝寻花一区二区三区| 精品福利一区二区三区免费视频| 一区二区三区在线免费观看| 成人激情综合网站| 久久久久久久久伊人| 裸体健美xxxx欧美裸体表演| 91久久精品一区二区| 国产精品久久久久久久岛一牛影视| 久久97超碰色| 在线不卡中文字幕| 性做久久久久久| 色婷婷久久久久swag精品| 国产精品三级av| 国产精品一区久久久久| 日韩精品在线网站| 裸体在线国模精品偷拍| 欧美一级免费大片| 日本一不卡视频| 欧美一区二区三区影视| 午夜精品一区二区三区三上悠亚| 在线视频中文字幕一区二区| 亚洲欧洲www| 91亚洲国产成人精品一区二三| 国产精品久久99| 99精品久久只有精品| 在线观看视频一区| 精品一区二区三区香蕉蜜桃| 日韩一区有码在线| 日韩国产高清在线| 国产亚洲欧美日韩在线一区| 99精品热视频| 日韩av一区二区三区四区| 日本一区二区在线不卡| 日韩视频在线一区二区| 国产精品中文字幕欧美| 亚洲天堂精品视频| 精品噜噜噜噜久久久久久久久试看 | 婷婷中文字幕综合| 国产91色综合久久免费分享| 国产农村妇女精品| 风间由美一区二区三区在线观看| 欧美国产激情二区三区 | 久久精品国产亚洲a| 精品国产a毛片| 成人免费看视频| 亚洲免费观看在线视频| 91黄视频在线观看| 日本麻豆一区二区三区视频| 精品国产91洋老外米糕| 国产成人亚洲精品青草天美| 国产精品夫妻自拍| 欧美性猛交xxxx乱大交退制版| 五月婷婷久久丁香| 精品1区2区在线观看| 不卡av电影在线播放| 亚洲国产综合视频在线观看| 日韩欧美综合一区| 国产91精品在线观看| 亚洲一区二区美女| 日韩欧美国产1| 成人a区在线观看| 日韩国产一二三区|