#include<stdio.h>
#include<string.h>
int r=0; //余数
struct bign{
int d[1000];
int len;
bign(){
memset(d,0,sizeof(d));
len=0;
}
};
bign change(char str[]){ //将字符数组转换成bign
bign a;
a.len=strlen(str);
for(int i=0;i<a.len;i++){
a.d[i]=str[a.len-i-1]-'0';
}
return a;
}
bign add(bign a,bign b){
bign c;
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;
carry=temp/10;
}
if(carry!=0){ //如果最终的进位不为0
c.d[c.len++]=carry;
}
return c;
}
bign sub(bign a,bign b){
bign c;
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];
}
while(c.len-1>=1&&c.d[c.len-1]==0){
c.len--;
}
return c;
}
bign multi(bign a,int b){
bign c;
int carry=0;
for(int i=0;i<a.len;i++){
int temp=a.d[i]*b+carry;
c.d[c.len++]=temp%10;
carry=temp/10;
}
while(carry!=0){
c.d[c.len++]=carry%10;
carry/=10;
}
return c;
}
bign divide(bign a,int b,int& r){
bign c;
c.len=a.len; //被除数的每一位和商的每一位是一一对应的,所以先令长度相等
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--; //去处高位的0,同时至少保证一位最低位
}
return c;
}
void print(bign a){
for(int i=a.len-1;i>=0;i--){
printf("%d",a.d[i]);
}
}
int main(){
char str1[1000],str2[1000];
scanf("%s%s",str1,str2);
bign a=change(str1);
bign b=change(str2);
printf(" a + b = ");
print(add(a,b));
printf("\n a - b = ");
print(sub(a,b));
printf("\n");
int c;
scanf("%d",&c);
printf(" a * c = ");
print(multi(a,c));
printf("\n a / c = ");
print(divide(a,c,r));
return 0;
}