标签:eof ret -- algo namespace emc space logs log
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 void r(int *a) 6 { 7 string b;cin>>b; 8 int l=b.length(); 9 for (int i=1;i<=l;i++) a[i]=b[l-i]-‘0‘; 10 a[0]=l; 11 } 12 void w(int *a) {for (int i=a[0];i>=1;i--) cout<<a[i];cout<<endl;} 13 void cls(int *a) {memset(a,0,sizeof(int)*(a[0]+1));} 14 void cpy(int *a,int *b) {memcpy(b,a,sizeof(int)*(a[0]+1));} 15 bool cmp(int *a,int *b) {for (int i=0;i<=a[0];i++) if (a[i]!=b[i]) return a[i]>b[i];} 16 void add(int *a,int *b,int *c) 17 { 18 cls(c);int l=1; 19 while (l<=a[0]||l<=b[0]) { 20 c[l+1]=(c[l]+=a[l]+b[l])/10; 21 c[l++]%=10; 22 } 23 if (!c[l]) l--;c[0]=l; 24 } 25 void mul(int *a,int *b,int *c) 26 { 27 cls(c);int la=a[0],lb=b[0],l=la+lb; 28 for (int i=1;i<=la;i++) for (int j=1;j<=lb;j++) { 29 c[i+j]+=(c[i+j-1]+=a[i]*b[j])/10; 30 c[i+j-1]%=10; 31 } 32 while (c[l]==0&&l>1) l--;c[0]=l; 33 } 34 void dmul(int *a,int b,int *c) 35 { 36 cls(c);int l=1; 37 while (l<=a[0]||c[l]) { 38 c[l+1]=(c[l]+=a[l]*b)/10; 39 c[l++]%=10; 40 } 41 while (c[l]==0&&l>1) l--;c[0]=l; 42 } 43 void ddiv(int *a,int b,int *c) 44 { 45 cls(c);int l=a[0]; 46 for (int i=l;i>=1;i--) { 47 c[i-1]=(c[i]+=a[i])%b*10; 48 c[i]/=b; 49 } 50 while (c[l]==0&&l>1) l--;c[0]=l; 51 }
标签:eof ret -- algo namespace emc space logs log
原文地址:http://www.cnblogs.com/algonote/p/6896625.html