27 August

高精度

struct bigint{
	int a[1000],an;
	bigint operator = (int b){
		an=0;
		while (b){a[an++]=b%10;b/=10;}
		return *this;
	}
	bigint operator *= (long long b){
		long long c=0,temp=0;
		for (int i=0;i<min(an,50);i++){
			temp=(a[i]*b+c);
			a[i]=temp%10;
			c=temp/10;
		}
		while (c&&an<=50) {a[an++]=c%10;c/=10;}
		return *this;
	}
};
void write(bigint x){
	if(x.an==0){printf("0\n");return;}
	bool qz=true;
	for (int i=min(x.an-1,49);i>=0;i--){
		if (qz&&x.a[i]==0);
		else {qz=false; printf("%d",x.a[i]);}
	}
	if (qz) printf("0\n");
}
int read(){
	int out=0;
	char cc=getchar();
	while (cc>'9'||cc<'0') cc=getchar();
	while (cc>='0'&&cc<='9'){out=out*10+cc-'0';cc=getchar();}
	return out;
}
posted @ 2019-08-27 20:51  greyqz  阅读(194)  评论(0编辑  收藏  举报