struct nd { int len,nl[maxn]; nd() { len=0; memset(nl,0,sizeof nl); } bool operator<(nd y) { if(len<y.len)return true; if(len>y.len)return false; frd(i,len-1,0) if(nl[i]<y.nl[i])return true; else if(nl[i]>y.nl[i])return false; return false; } nd operator-(nd y) { nd as; as.len=len; fru(i,0,len-1) { as.nl[i]+=nl[i]-y.nl[i]; if(as.nl[i]<0) { as.nl[i+1]--; as.nl[i]+=bs; } } while(as.len>1&&as.nl[as.len-1]==0)as.len--; return as; } nd operator*(int y) { nd as; as.len=len; fru(i,0,len-1) { as.nl[i]+=nl[i]*y; if(as.nl[i]>=bs) { as.nl[i+1]+=as.nl[i]/bs; as.nl[i]%=bs; } } while(as.nl[as.len]){as.len++; as.nl[as.len]+=as.nl[as.len-1]/bs; as.nl[as.len-1]%=bs; } return as; } nd operator/(int y) { nd as;int tmp; as.len=len; frd(i,len-1,0) { tmp=as.nl[i]+nl[i]; (as.nl[i]+=nl[i])/=y; as.nl[i-1]+=(tmp-as.nl[i]*y)*bs; } while(as.len>1&&as.nl[as.len-1]==0)as.len--; return as; } };
|