#include "cstdio"
#include "string"
#include "iostream"
using namespace std;
const int MAXN = 10;
struct bigInt {
int d[MAXN];
int len;//大整数的位数
};
bigInt change(string str) {//存一个大整数
bigInt bI;
bI.len = str.size();
for (int i = 0; i < MAXN; ++i) {
bI.d[i] = 0;//初始化都设置为0
}
for (int i = 0; i < bI.len; ++i) {
bI.d[i] = str[bI.len - i - 1] - '0';//倒序输入,使低位对齐,便于加减乘操作
}
return bI;
}
bigInt add(bigInt a, bigInt b) {//大整数相加
bigInt c;
c.len = 0;
int carry = 0;//保存进位
for (int i = 0; i < a.len || i < b.len; ++i) {
int temp = a.d[i] + b.d[i] + carry;
c.d[c.len] = temp % 10;
c.len++;
carry = temp / 10;
}
if (carry != 0) {
c.d[c.len] = carry;
c.len++;
}
return c;
}
bigInt sub(bigInt a, bigInt b) {//减法
bigInt c;
c.len = 0;
for (int i = 0; i < a.len || i < b.len; ++i) {
if (a.d[i] < b.d[i]) {
a.d[i + 1]--;
a.d[i] += 10;
}
c.d[c.len] = a.d[i] - b.d[i];
c.len++;
}
while (c.len - 1 >= 1 && c.d[c.len - 1] == 0) {
c.len--;
}
return c;
}
bigInt multi(bigInt a, int b) {//乘法
bigInt c;
c.len = 0;
int carry = 0;
for (int i = 0; i < a.len; ++i) {
int temp = a.d[i] * b + carry;
c.d[c.len] = temp % 10;
c.len++;
carry = temp / 10;
}
while (carry != 0) {
c.d[c.len] = carry % 10;
c.len++;
carry /= 10;
}
return c;
}
bigInt divide(bigInt a, int b, int &r) {//除法,b为除数,r为余数
bigInt c;
c.len = a.len;
r = 0;
for (int i = a.len - 1; i >= 0; i--) {
r = r * 10 + a.d[i];
if (r < b) {
c.d[i] = 0;
} else {
c.d[i] = r / b;
r = r % b;
}
}
while (c.len - 1 >= 1 && c.d[c.len - 1] == 0) {
c.len--;
}
return c;
}
int main() {
bigInt a, b, answer, answer2, answer3, answer4;
string stra, strb;
while (cin >> stra >> strb) {
a = change(stra);
b = change(strb);
answer = add(a, b);
for (int i = answer.len - 1; i >= 0; i--) {
cout << answer.d[i];
}
printf("\n");
answer2 = sub(a, b);
for (int i = answer2.len - 1; i >= 0; i--) {
cout << answer2.d[i];
}
printf("\n");
answer3 = multi(a, 3);
for (int i = answer3.len - 1; i >= 0; i--) {
cout << answer3.d[i];
}
printf("\n");
int r = 0;
answer4 = divide(a, 3, r);
for (int i = answer4.len - 1; i >= 0; i--) {
cout << answer4.d[i] << endl;
}
cout << r << endl;
}
return 0;
}
大整数相加、大整数相减、大整数乘小整整数、大整数除小整整数和取模