{ int i; if(b==0)len=1; for(i=0;b;i++){ a[i]=b%base; b/=base; } len=i; } void output()const { for(int i=len-1;i>=0;i--){ printf("%d",a[i]); } puts(""); } Num operator *(const Num &b)const{ Num c; for(int i=0;i<len;i++) for(int j=0;j<b...
} While this algorithm is relatively efficient, performing in liner time or O(n), it could be improved. In fact we could do the same task in O(log(n)+log(n)). How? By using a method calledexponentiation by squaring. Here’s the basic idea: for any a^b, if a b is even we c...