乘法:
vector<int> mul(vector<int>a,int b) { vector<int>c; int t=0; for(int i=0;i<a.size();++i) { t+=a[i]*b; c.pb(t%10); t/=10; } while(t) c.pb(t%10),t/=10; return c; }
除法:
vector<int> div(vector<int>a,int b) { vector<int>c; bool is_first=false; int t=0; for(int i=a.size()-1;i>=0;--i) { t=t*10+a[i]; int x=t/b; if(is_first||x) { is_first=true; c.pb(x); } t%=b; } reverse(c.begin(),c.end()); return c; }
减法:
inline vector<int> sub(vector<int>a,vector<int>b) { vector<int>c; for(int i=0;i<max(a.size(),b.size());++i) { int d=a[i]-(i<b.size()?b[i]:0); if(d<0) --a[i+1],c.pb(10+d); else c.pb(d); } while(c.size()&&c.back()==0) c.pop_back(); return c; }