#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
void reserve(char *a){
int i = 0;
int j = strlen(a)-1;
while(i < j){
char temp = a[i];
a[i++] = a[j];
a[j--] = temp;
}
}
void add(char a[], char b[], char *result){
reserve(a);
reserve(b);
for(int i = 0; i < int(strlen(b)); i++){
for(int j = 0; j < int(strlen(a)); j++){
int x = a[j] - '0';
int y = b[i] - '0';
int mul = x * y + (result[i+j]-'0');
result[i+j] = mul % 10 + '0';
result[i+j+1] += mul / 10;
}
}
}
int main(){
char a[100010];
char b[100010];
scanf("%s %s", a, b);
int n = strlen(a);
int m = strlen(b);
char c[n+m];
memset(c, '0', sizeof(c));
if(strlen(a) < strlen(b))
add(b, a, c);
else
add(a, b, c);
reserve(c);
int k = 0;
for(int i = 0; i < int(strlen(c)); i++){
if(c[i] >= 49 && c[i] <= 57){
k = i;
break;
}
}
for(int i = k; i < int(strlen(c)); i++)
printf("%c", c[i]);
return 0;
}
|