1 #include <cstdio> 2 #include <cstring> 3 char x[10001]; 4 int a[2][10001],len[3],c[10001]; 5 int main() 6 { 7 memset(a,0,sizeof(a)); 8 memset(c,0,sizeof(c)); 9 for(int q = 0;q <= 1;q++){ 10 gets(x + 1); 11 int l = strlen(x + 1),t = 0,pos = 0; 12 int tmp = len[q] = l % 4 == 0 ? l / 4 : l / 4 + 1; 13 for(int i = 1;i <= l;i++){ 14 t = t * 10 + x[i] - '0'; 15 if(i % 4 == 0 || i == l) 16 a[q][tmp--] = t,t = 0; 17 } 18 }len[2] = len[0] >= len[1] ? len[0] : len[1]; 19 for(int i = 1;i <= len[0];i++){ 20 printf("%d ",a[0][i]); 21 } 22 for(int i = 1;i <= len[0];i++){ 23 for(int j = 1;j <= len[1];j++){ 24 c[i + j] += a[0][i] * a[1][j]; 25 if(c[i + j] >= 10000){ 26 c[i + j + 1] += c[i + j] / 10000; 27 c[i + j] %= 10000; 28 } 29 } 30 } 31 if(c[len[3]] > 0)len[3]++; 32 for(int i = len[3];i >= 1;i--){ 33 printf("%.4d",c[i]); 34 } 35 return 0; 36 } 37