//大数模板
#include<stdio.h>
#include<queue>
#include<string.h>
#include<algorithm>
using namespace std;
const int SIZE = 7;// 不允许更改
const int mod = 1000000000;// 不允许更改
#define ll long long
#define N 1000
struct bignum // 结构体 重载大数操作 //* 特别提醒 *// 不支持负数操作 或产生负数的操作 也不支持分数操作 不同的操作的位数不同 乘法结果不大于 10^36
{
long long a[SIZE];
bignum()
{
memset(a, 0, sizeof(a));
}
bignum(long long n) // 给该结构结构赋值 调用 ans1=bignum(n),ans2=bignum(m) ; 等价 ans1=n ,ans2=m;
{
memset(a, 0, sizeof(a));
a[0] = n;
adjust();
}
void adjust()
{
for (int i = 0; i < SIZE; i++)
if (a[i] >= mod)
{
a[i + 1] += a[i] / mod;
a[i] %= mod;
}
else if (a[i] < 0)
{
a[i + 1] --;
a[i] += mod;
}
}
bignum operator * (const bignum &p) // 结构与结构之间的乘法 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1*ans2; 等价于 ans=n*m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
for (int j = 0; i + j < SIZE; j++)
c.a[i + j] += a[i] * p.a[j];
c.adjust();
return c;
}
bignum operator / (const int x) // 结构与 int 型数除法 ans1=bignum(n),m 如 ans=ans1/m; 等价于 ans=n/m;
{
long long tmp = 0;
bignum c;
memcpy(c.a, a, sizeof(a));
for (int i = SIZE - 1; i >= 0; i--)
{
long long p = (tmp * mod + c.a[i]) % x;
c.a[i] = (tmp * mod + c.a[i]) / x;
tmp = p;
}
return c;
}
bignum operator + (const bignum &p) // 结构之间的加法 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1+ans2 ; 等价于 ans=n+m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
c.a[i] = a[i] + p.a[i];
c.adjust();
return c;
}
bignum operator - (const bignum &p) // 只允许大数 减小数 不允许负数和零 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1+ans2 ; 等价于 ans=n+m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
c.a[i] = a[i] - p.a[i];
c.adjust();
return c;
}
bool operator == (const bignum &p) // 结构之间相互赋值 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1 ; 等价于 ans=n ;
{
for (int i = 0; i < SIZE; i++)
if (a[i] != p.a[i]) return false;
return true;
}
void output() // 输出结构中的数
{
int i = SIZE - 1;
for (i; i >= 0; i--)
{
if (a[i]) break;
}
printf("%lld", a[i]);
for (i = i - 1; i >= 0; i--)
printf("%09lld", a[i]);
printf("\n");
}
};
int main()
{
ll n, sum;
while (scanf("%lld%lld", &n,&sum) != EOF)
{
bignum ans;
ans = bignum(0); // ans=0;
ans = bignum(n) + bignum(sum);
ans.output();
ans = bignum(n) - bignum(sum);
ans.output();
ans = bignum(n) * bignum(sum);
ans.output();
ans = bignum(n)/sum; // 只满足整除的情况
ans.output();
}
return 0;
}
#include<stdio.h>
#include<queue>
#include<string.h>
#include<algorithm>
using namespace std;
const int SIZE = 7;// 不允许更改
const int mod = 1000000000;// 不允许更改
#define ll long long
#define N 1000
struct bignum // 结构体 重载大数操作 //* 特别提醒 *// 不支持负数操作 或产生负数的操作 也不支持分数操作 不同的操作的位数不同 乘法结果不大于 10^36
{
long long a[SIZE];
bignum()
{
memset(a, 0, sizeof(a));
}
bignum(long long n) // 给该结构结构赋值 调用 ans1=bignum(n),ans2=bignum(m) ; 等价 ans1=n ,ans2=m;
{
memset(a, 0, sizeof(a));
a[0] = n;
adjust();
}
void adjust()
{
for (int i = 0; i < SIZE; i++)
if (a[i] >= mod)
{
a[i + 1] += a[i] / mod;
a[i] %= mod;
}
else if (a[i] < 0)
{
a[i + 1] --;
a[i] += mod;
}
}
bignum operator * (const bignum &p) // 结构与结构之间的乘法 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1*ans2; 等价于 ans=n*m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
for (int j = 0; i + j < SIZE; j++)
c.a[i + j] += a[i] * p.a[j];
c.adjust();
return c;
}
bignum operator / (const int x) // 结构与 int 型数除法 ans1=bignum(n),m 如 ans=ans1/m; 等价于 ans=n/m;
{
long long tmp = 0;
bignum c;
memcpy(c.a, a, sizeof(a));
for (int i = SIZE - 1; i >= 0; i--)
{
long long p = (tmp * mod + c.a[i]) % x;
c.a[i] = (tmp * mod + c.a[i]) / x;
tmp = p;
}
return c;
}
bignum operator + (const bignum &p) // 结构之间的加法 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1+ans2 ; 等价于 ans=n+m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
c.a[i] = a[i] + p.a[i];
c.adjust();
return c;
}
bignum operator - (const bignum &p) // 只允许大数 减小数 不允许负数和零 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1+ans2 ; 等价于 ans=n+m;
{
bignum c;
for (int i = 0; i < SIZE; i++)
c.a[i] = a[i] - p.a[i];
c.adjust();
return c;
}
bool operator == (const bignum &p) // 结构之间相互赋值 ans1=bignum(n),ans2=bignum(m) 如 ans=ans1 ; 等价于 ans=n ;
{
for (int i = 0; i < SIZE; i++)
if (a[i] != p.a[i]) return false;
return true;
}
void output() // 输出结构中的数
{
int i = SIZE - 1;
for (i; i >= 0; i--)
{
if (a[i]) break;
}
printf("%lld", a[i]);
for (i = i - 1; i >= 0; i--)
printf("%09lld", a[i]);
printf("\n");
}
};
int main()
{
ll n, sum;
while (scanf("%lld%lld", &n,&sum) != EOF)
{
bignum ans;
ans = bignum(0); // ans=0;
ans = bignum(n) + bignum(sum);
ans.output();
ans = bignum(n) - bignum(sum);
ans.output();
ans = bignum(n) * bignum(sum);
ans.output();
ans = bignum(n)/sum; // 只满足整除的情况
ans.output();
}
return 0;
}