#include<iostream> #include<string> using namespace std; int main(){ string str1, str2; while (cin >> str1 >> str2){ int s1 = str1.size(); int s2 = str2.size(); if (s1 > s2){ for (int i = 0; i < s1 - s2; i++){ str2.insert(0,"0"); } } if (s2 > s1){ for (int i = 0; i < s2 - s1; i++){ str1.insert(0, "0"); } } string add = str1; string sub = str1; int k=0, m; for (int i = add.size() - 1; i >= 0; i--){ //加法 m = add[i] - '0' + str2[i] - '0' + k; k = m / 10; add[i] = m % 10 + '0'; } if (k>0){ add.insert(0,"1"); } cout << add << endl; if (s1 > s2 || s1 == s2&&str1 > str2){ for (int i = sub.size() - 1; i >= 0; i--){ //减法 if (sub[i] >= str2[i]){ sub[i] = sub[i] - str2[i] + '0'; } else{ sub[i] = 10 + sub[i] - str2[i] + '0'; sub[i - 1]--; } } while (sub[0] == '0'&&sub.size()>1){ sub.erase(0, 1); } } else{ sub = str2; for (int i = sub.size() - 1; i >= 0; i--){ //减法 if (sub[i] >= str1[i]){ sub[i] = sub[i] - str1[i] + '0'; } else{ sub[i] = 10 + sub[i] - str1[i] + '0'; sub[i - 1]--; } } while (sub[0] == '0'&&sub.size()>1){ sub.erase(0, 1); } sub.insert(0, "-"); } cout<< sub << endl; string ans; //最终结果 string mut; //中间结果 for (int i = str1.size() - 1; i >= 0; i--){ //乘法 int x = 0, y = 0; for (int j = str2.size()-1; j >= 0; j--){ x = (str1[i] - '0')*(str2[j] - '0') + y; y = x / 10; mut.insert(0, 1, x % 10 + '0'); } if (y > 0){ mut.insert(0, 1,y+'0'); } mut.insert(mut.size(), str1.size() - 1 - i, '0'); if (i == str1.size()-1){ ans = mut; } else{ int z1 = mut.size(), z2 = ans.size(); if (z1 > z2){ for (int i = 0; i < z1 - z2; i++){ ans.insert(0, "0"); } } if (z2 > z1){ for (int i = 0; i < z2 - z1; i++){ mut.insert(0, "0"); } } int p = 0, q = 0; for (int i = ans.size() - 1; i >= 0; i--){ //中间结果加最终结果 p = ans[i] - '0' + mut[i] - '0' + q; q = p / 10; ans[i] = p % 10 + '0'; } if (q>0){ ans.insert(0, "1"); } } mut.clear(); } while (ans[0] == '0'&&ans.size()>1){ ans.erase(0, 1); } cout << ans << endl; } }