1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N = 1e5; 4 char A[N],B[N]; 5 int a[N],b[N],c[N],na,nb; 6 void change(){ 7 for(int i=0; i<na; i++){ 8 a[na-i] = A[i] - '0'; 9 } 10 for(int i=0; i<nb; i++){ 11 b[nb-i] = B[i] - '0'; 12 } 13 } 14 int main(){ 15 scanf("%s%s",A,B); 16 na = strlen(A); 17 nb = strlen(B); 18 change(); 19 for(int i=1; i<=na; i++){ 20 for(int j=1; j<=nb; j++){ 21 c[i+j-1] += a[i]*b[j]; 22 c[i+j] += c[i+j-1] / 10; 23 c[i+j-1] %= 10; 24 } 25 } 26 int nc = na+nb; 27 while(nc > 1 && !c[nc]) nc--; 28 for(int i=nc; i>=1; i--){ 29 printf("%d",c[i]); 30 } 31 return 0; 32 }
最新评论