都是自己手写的,重载运算符用起来也比较方便
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
int read(){
int x = 1,a = 0;char ch = getchar();
while (ch < '0'||ch > '9'){if (ch == '-') x = -1;ch = getchar();}
while (ch >= '0'&&ch <= '9'){a = a*10+ch-'0';ch = getchar();}
return x*a;
}
struct INT{
int len,a[10007];
void clear(){len = 1,memset(a,0,sizeof(a));}
void print(){
for (int i = len;i >= 1;i--) putchar(a[i]+'0');
puts("");
}
void read(){
char ch = getchar();clear();len = 0;
while (ch < '0'||ch > '9') ch = getchar();
while (ch >= '0'&&ch <= '9'){a[++len] = ch-'0';ch = getchar();}
for (int i = 1;i < len-i+1;i++) swap(a[i],a[len-i+1]);
}
void calc(){
for (int i = 1;i <= len;i++){
if (a[i] >= 10) a[i+1] += a[i]/10,a[i] %= 10,len = max(len,i+1);
}
}
void operator = (int b){
clear();len = 0;
while (b) a[++len] = b%10,b /= 10;
len = max(1,len);
}
friend INT operator + (const INT a,const INT b){
INT res;res.clear();res.len = max(a.len,b.len);
for (int i = 1;i <= res.len;i++) res.a[i] = a.a[i] + b.a[i];
res.calc();return res;
}
friend INT operator + (const INT a,const int b){
INT c;c = b;return a+c;
}
friend INT operator - (const INT a,const INT b){
INT res;res.clear();res.len = max(a.len,b.len);
for (int i = 1;i <= res.len;i++) res.a[i] = a.a[i] - b.a[i];
for (int i = 1;i <= res.len;i++){
if (res.a[i] < 0) res.a[i] += 10,res.a[i+1] --;
}
while (!res.a[res.len]&&res.len > 1) res.len--;
return res;
}
friend INT operator - (const INT a,const int b){
INT c;c = b;return a-c;
}
friend INT operator * (const INT a,const INT b){
INT res;res.clear();res.len = a.len+b.len-1;
for (int i = 1;i <= a.len;i++){
for (int j = 1;j <= b.len;j++) res.a[i+j-1] += a.a[i] * b.a[j];
}
res.calc();return res;
}
friend INT operator * (const INT a,const int b){
INT c;c = b;return a*c;
}
friend INT operator / (const INT a,const int b){
INT res;res.clear();res.len = a.len;int tmp = 0;
for (int i = 1;i <= res.len;i++){
tmp = tmp*10+a.a[i];
res.a[i] = tmp/b,tmp %= b;
}
while (!res.a[res.len]&&res.len > 1) res.len--;
return res;
}
friend int operator % (const INT a,const int b){
int tmp = 0;
for (int i = 1;i <= a.len;i++){
tmp = tmp*10+a.a[i];
tmp %= b;
}
return tmp;
}
};
int main(){
INT a,b;int c = read();
a.read(),b.read();
INT ans,ans1,ans2,ans3;
ans = a+b,ans1 = a-b;
ans2 = a/c,ans3 = a%c;
ans.print(),ans1.print(),ans2.print(),ans3.print();
return 0;
}