#include <iostream>
#include <cstdio>
using namespace std;
class Decimal
{
// (SIZE * KETA) 未満の整数を扱える
static const int SIZE = 1000;
static const unsigned long KETA = 10000;
public:
Decimal() { init(); }
Decimal(unsigned long n) {
init();
int i = 0;
while (n > 0) {
value[i] = n % KETA;
n /= KETA;
i++;
}
}
Decimal(const Decimal& v) {
for (int i = 0; i <= SIZE; i++) {
value[i] = v.value[i];
}
}
Decimal operator + (const Decimal& add) {
Decimal sum(add);
for (int i = 0; i < SIZE; i++) {
sum.value[i] += value[i];
sum.value[i + 1] += sum.value[i] / KETA;
sum.value[i] %= KETA;
}
if (sum.value[SIZE] > 1) {
sum.value[SIZE] = 1;
}
return sum;
}
Decimal operator * (const Decimal& mul) {
Decimal pdt;
for (int i = 0; i < SIZE; i++){
for (int j = 0; i + j < SIZE; j++) {
pdt.value[i + j] += value[i] * mul.value[j];
}
pdt.value[i + 1] += pdt.value[i] / KETA;
pdt.value[i] %= KETA;
}
if (pdt.value[SIZE] > 1) {
pdt.value[SIZE] = 1;
}
return pdt;
}
Decimal& operator += (const Decimal& add) {
for (int i = 0; i < SIZE; i++) {
value[i] += add.value[i];
value[i + 1] += value[i] / KETA;
value[i] %= KETA;
}
if (value[SIZE] > 1) {
value[SIZE] = 1;
}
return *this;
}
Decimal& operator *= (const Decimal& mul) {
Decimal tmp(*this);
init();
for (int i = 0; i < SIZE; i++){
for (int j = 0; i + j < SIZE; j++) {
value[i + j] += tmp.value[i] * mul.value[j];
}
value[i + 1] += value[i] / KETA;
value[i] %= KETA;
}
if (value[SIZE] > 1) {
value[SIZE] = 1;
}
return *this;
}
void print() const {
int f = 0;
for (int i = SIZE; --i >= 0; ) {
if (f == 0) {
if (value[i] == 0) {
continue;
}
f = 1;
cout << value[i];
} else {
printf("%04d", value[i]);
}
}
if (f == 0) {
putchar('0');
}
if (value[SIZE] != 0) {
cout << "[OF]";
}
}
void println() const {
print();
cout << endl;
}
private:
void init() {
for (int i = 0; i <= SIZE; i++) {
value[i] = 0;
}
}
unsigned long value[SIZE + 1];
};
int main() {
unsigned long n = 0xFFFFFFFFUL;
Decimal val1(n);
Decimal val2(val1);
Decimal val3(val1 + val2);
Decimal val4, val5, val6;
Decimal val7(10000002), val8, val9;
cout << n << endl;
val1.println();
val2.println();
val3.println();
val4 = val1 + val2 + val3;
val4.println();
val5 = val1 + 100000001;
val5.println();
val6 = val4 + val4 + val4 + val4;
val6.println();
val7 = val7 * val7 * val7 * val7;
val8 = val7 * val7 * val7;
val8 = val8 * val8 * val8 * val8;
val8 = val8 * val8 * val8;
val7.println();
val8.println();
val9 += 100;
val9 += 200;
val9.println();
val9 = Decimal(111111111) * Decimal(7);
val9.println();
val9 = 111111111;
val9 *= 3;
val9.println();
return 0;
}