Arithmetic Operations With Large Integers |
This problem is about calculations with large numbers. Large means numbers with at most one thousand digits. The operations are limited to addition, substraction, multiplication and raising to a higher power.
There are no limitations to the operants of addition, substraction and multiplication. The base in raising to higher powers is positive and smaller than ten. The exponent is positive.
The inputfile consists of a valid expression with any number of operations. There are no parentheses, but the normal arithmetic priority rules are still valid.
An example of a valid expression is: 12345678 * 129876 + 2**1993. An invalid expression is: 12345678 * 129876 + 12**1993 because the base is greater than nine.
The file contains numbers and operands in the following way: n op n { op n } . n is a positive decimal number with at most one thousand digits, stored as an ASCII-text. op is one of the following: +, -, *,** (** means ``raising to higher powers''). There can be at most one hundred operations. There are no spaces or other illegal characters in the inputfile.
The outputfile is also a textfile of maximal three thousand characters. It contains the exact result of the evaluated expression given in the inputfile. The output is terminated by the standard end of file, and must not contain any other characters.
12345678*129876+2**1993
896977105683011347056900938420064050017435704756793125373158388145129891712\\ 789307700515223684770523373785909874208955291755561688174261977676508872005\\ 197801086953040197752187505381087095625350558038492109870986287356370809737\\ 409093338414265941143390397695285610643740694879918793932122262001282984143\\ 224073001319601441082075018589725061828585163552941409601583724270514300953\\ 188533095947591884905338415676554651534516617357655143781579373852994152663\\ 198702360093129335607684294312805938140290754926427776409574872859496315224\\ 89390181292585090592061583009183090068756428459147015355107518672556877720