13519 - Big Integer 2   

Description

This is a problem extended from Problem 13487 (nthu.edu.tw).

Instead of doing addition, you are asked to implement the operator * to perform multiplication.

The following is the class INT:

#include <iostream>
class INT {
    public:
        INT();
        void mulby10();
        INT operator=(INT);
        INT operator+(INT);
        INT operator*(INT);
        friend std::istream &operator>>(std::istream &, INT &);
        friend std::ostream &operator<<(std::ostream &, INT);
    private:
        char *data;
        int len;
};

 Except INT operator*(INT), other functions has been implemented and provided in main.cpp. You should check how the operators +>>, << are implemented and how the data is stored.

Note that additional tool mulby10() is provided to multiply INT by 10. For instance:

INT a;  // Suppose that a = 1234
cout << a << endl; // Print: 1234
a.mulby10();
cout << a << endl; // Print: 12340

You have two ways to implement the multiplication:

  1. Perform long multiplication (直式乘法). Be careful of overflow problem since char can only holds data from 0 to 255 (28-1).
  2. Break the multiplication into several additions:
    456*123=456*(100+20+3)=456*(100+10+10+1+1+1)

Input

There are two lines. Each line has a single integer.

No leading 0's are given in the test cases. E.g. 0001239487. 

The total length of the two integers is at most 10000 characters.

Output

Compute and output the product of the two integers.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13519.cpp

Partial Judge Header

13519.h

Tags




Discuss