class Big{ public: int size,num[2001]; Big(){size=0;memset(num,0,sizeof num);} Big(int data){ size=0; while(data!=0) { size++; num[size]=data%M;data/=M; } } inline void init(int data){ size=0; while(data!=0) { size++; num[size]=data%M;data/=M; } } inline void copy(Big A){ int s1=size,s2=A.size; size=s2; for(int i=s2;i>=1;i--) num[i]=A.num[i]; } }; inline int read() { int x=0,f=1;char c=getchar(); while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=x*M+c-'0';c=getchar();} return x*f; } Big operator + (Big A,Big B) { Big C;C.init(0); C.size=max(A.size,B.size); for(int i=1;i<=C.size;i++) { C.num[i]+=A.num[i]+B.num[i]; C.num[i+1]+=C.num[i]/M,C.num[i]%=M; } if(C.num[C.size+1]!=0) C.size++; return C; } Big operator - (Big A,Big B) { Big C; C.size=max(A.size,B.size); for(int i=1;i<=C.size;i++) { C.num[i]+=A.num[i]-B.num[i]; if(C.num[i]<0) C.num[i+1]--,C.num[i]+=M; } while(!C.num[C.size]) C.size--; return C; } Big operator * (Big A,Big B) { Big C;int s=A.size,s_=B.size; C.size=A.size+B.size; for(int i=1;i<=s;i++) for(int j=1;j<=s_;j++) { C.num[i+j-1]+=A.num[i]*B.num[j]; if(C.num[i+j-1]>M) C.num[i+j]+=C.num[i+j-1]/M,C.num[i+j-1]%=M; } while(!C.num[C.size]) C.size--; return C; } Big operator /(Big A,int b) { Big C; int s1=A.size,k;k=s1; for(int i=s1;i>=1;i--) { C.num[i]=A.num[i]/b; if(i!=1) A.num[i-1]+=(A.num[i]%b*10); A.num[i]/=b; } while(k>=1 && C.num[k]==0) k--;C.size=k; return C; } ostream & operator << (ostream &os,Big A) { int s=A.size; os<<A.num[s]; for(int i=s-1;i;i--) os<<setfill('0')<<setw(4)<<A.num[i]; return os; } //说明 赋值: Big A;A.init(x);//x为int Big A,B;A.copy(B);