zoukankan      html  css  js  c++  java
  • HISKrrr的板子库

    高精度
    struct node{
    	ll a[maxn<<1];
    	int len;
    	node () {len = 0; memset(a,0,sizeof(a));}
    	friend node operator +(node A,node B) {
    		node C;
    		if(A.a[0] && !B.a[0]) {A.a[0] = 0; return B - A;}
    		if(!A.a[0] && B.a[0]) {B.a[0] = 0; return A - B;}
    		if(A.a[0] && B.a[0]) C.a[0] = 1;
    		for(rint i = 1;i <= max(A.len,B.len);++i) C.a[i] = A.a[i] + B.a[i];
    		for(rint i = 1;i <= max(A.len,B.len);++i) C.a[i] += C.a[i-1] / mod,C.a[i-1] %= mod;
    		C.len = max(A.len,B.len);
    		while(C.a[C.len+1]) C.len++;
    		return C;
    	}
    	friend node operator -(node A,node B) {
    		node C;
    		if(A.a[0] && !B.a[0]) {B.a[0] = 1; return A + B;}
    		if(!A.a[0] && B.a[0]) {B.a[0] = 0; return A + B;}
    		if(A.a[0] && B.a[0]) {B.a[0] = 0; return A + B;}
    		if(A < B) {C = B - A,C.a[0] = 1; return C;}
    		C.len = 0;
    		for(rint i = max(A.len,B.len);i >= 1;--i) C.a[i] = A.a[i] - B.a[i];
    		for(rint i = 1;i <= max(A.len,B.len);++i) if(C.a[i] < 0) C.a[i] += mod,C.a[i+1]--;
    		for(rint i = max(A.len,B.len);i >= 1;--i) if(C.a[i]) {C.len = i; break;}
    		return C;
    	}
    	friend node operator *(node A,node B) {
    		node C; C.len = A.len + B.len - 1;
    		if(A.a[0] ^ B.a[0]) C.a[0] = 1;
    		for(rint i = 1;i <= A.len;++i) {
    			for(rint j = 1;j <= B.len;++j) {
    				C.a[i+j-1] += A.a[i] * B.a[j];
    				C.a[i+j] += C.a[i+j-1] / mod;
    				C.a[i+j-1] %= mod;
    			}
    		}
    		while(C.a[C.len+1]) C.len++;
    		return C;
    	}
    	friend node operator /(node A,int B) {
    		node C;
    		node D; D.push(B);
    		if(A < D) return C;
    		C = A;
    		rint flag = B < 0;
    		if(A.a[0] ^ flag) C.a[0] = 1;
    		else C.a[0] = 0;
    		for(rint i = A.len;i >= 1;--i) {
    			if(i != 1) C.a[i-1] += A.a[i] % B * mod;
    			C.a[i] /= B;
    		}
    		while(!C.a[C.len]) C.len--;
    		return C;
    	}
    	friend node operator +(node A,int B) {
    		A.a[1] += B;
    		for(rint i = 2;i <= A.len;++i) A.a[i] += A.a[i-1] / mod,A.a[i-1] %= mod;
                    while(A.a[A.len+1]) A.len++;
    		return A;
    	}
    	friend bool operator !(node A) {
    		for(rint i = 1;i <= A.len;++i) if(A.a[i]) return 0;
    		return 1;
    	}
    	friend bool operator >(node A,node B) {
    		rint flag = 0;
    		if(A.a[0] && !B.a[0]) return 0;
    		if(!A.a[0] && B.a[0]) return 1;
    		if(A.a[0] && B.a[0]) flag = 1;
    		if(A.len > B.len) return flag ? 0 : 1;
    		if(A.len < B.len) return flag ? 1 : 0;
    		for(rint i = A.len;i >= 1;--i) if(A.a[i] > B.a[i]) return flag ? 0 : 1; else if(A.a[i] < B.a[i]) return flag ? 1 : 0;
    		return 0;
    	}
    	friend bool operator <(node A,node B) {
    		rint flag = 0;
    		if(A.a[0] && !B.a[0]) return 1;
    		if(!A.a[0] && B.a[0]) return 0;
    		if(A.a[0] && B.a[0]) flag = 1;
    		if(A.len > B.len) return flag ? 1 : 0;
    		if(A.len < B.len) return flag ? 0 : 1;
    		for(rint i = A.len;i >= 1;--i) if(A.a[i] < B.a[i]) return flag ? 0 : 1; else if(A.a[i] > B.a[i]) return flag ? 1 : 0;
    		return 0;
    	}
    	friend bool operator ==(node A,node B) {
    		if(A.len ^ B.len) return 0;
    		for(rint i = 0;i <= A.len;++i) if(A.a[i] != B.a[i]) return 0;
    		return 1;
    	}
    	friend bool operator >=(node A,node B) {
    		rint flag = 0;
    		if(A.a[0] && !B.a[0]) return 0;
    		if(!A.a[0] && B.a[0]) return 1;
    		if(A.a[0] && B.a[0]) flag = 1;
    		if(A.len > B.len) return flag ? 0 : 1;
    		if(A.len < B.len) return flag ? 1 : 0;
    		for(rint i = A.len;i >= 1;--i) if(A.a[i] > B.a[i]) return flag ? 0 : 1; else if(A.a[i] < B.a[i]) return flag ? 1 : 0;
    		return 1;
    	}
    	friend bool operator <=(node A,node B) {
    		rint flag = 0;
    		if(A.a[0] && !B.a[0]) return 1;
    		if(!A.a[0] && B.a[0]) return 0;
    		if(A.a[0] && B.a[0]) flag = 1;
    		if(A.len > B.len) return flag ? 1 : 0;
    		if(A.len < B.len) return flag ? 0 : 1;
    		for(rint i = A.len;i >= 1;--i) if(A.a[i] < B.a[i]) return flag ? 0 : 1; else if(A.a[i] > B.a[i]) return flag ? 1 : 0;
    		return 1;
    	}
    	void read() {
    		char s[maxm] = {}; scanf("%s",s+1);
    		rint lenth = strlen(s+1);
    		for(rint i = lenth;i >= 1;i -= 8) {
    			++len;
    			for(rint j = min(8,i);j >= 1;--j) a[len] = a[len] * 10 + s[i-j+1] - '0';
    		}
    	}
    	void print () {
    		if(a[0]) printf("-");
    		printf("%lld",a[len]);
    		for(rint i = len - 1;i >= 1;--i) printf("%.8lld",a[i]);
    	}
    	void push (int x) {//低精赋值给高精
    		char s[maxm] = {};
    		rint cnt = 0;
    		while(x) {
    			s[++cnt] = x%10 + '0';
    			x /= 10;
    		}
    		reverse(s+1,s+cnt+1);
    		for(rint i = cnt;i >= 1;i -= 8) {
    			++len;
    			for(rint j = min(8,i);j >= 1;--j) a[len] = a[len] * 10 + s[i-j+1] - '0';
    		}
    	}
    	void clear () {memset(a,0,sizeof(a)); len = 0;}
    };
    
  • 相关阅读:
    UIButtonIOS开发
    SharePoint Server 2007 SP1 已发布
    SharePoint 2007 External Binary Storage Component Preview 发布
    WSS 3.0 & MOSS 2007 SDK 1.1
    SharePoint工作流(ASP.NET表单版)教学视频
    Finally...
    Windows SharePoint Services 3.0 "Visual How Tos" 视频系列
    SharePoint 补丁
    在SharePoint Workflow中使用InfoPath Form的几个Tips
    对于Office Open XML文档格式,请发表您的看法
  • 原文地址:https://www.cnblogs.com/2004-08-20/p/14058057.html
Copyright © 2011-2022 走看看