UVa 10700 - Camel trading

Summary
Given is an equation consisting of some positive integers, and + and * signs. Determine the maximal and the minimal value that can be obtained by adding parentheses into the expression.

Explanation
To find the maximum value, do the addition first, then the multiplication. Similiarly, to find the minimium value, do the multiplication first, then the addition.

Gotcha
Remember to use a 64-bit integer type as $$20^{12}$$ is bigger than $$2^{32}$$. (Refer to the sample input.)

= Input == 4 1+2*3*4+5 4*18+14+7*10 3+11+4*1*13*12*8+3*3+8 20*20*20*20*20*20*20*20*20*20*20*20

Output
The maximum and minimum are 81 and 30. The maximum and minimum are 1560 and 156. The maximum and minimum are 339768 and 5023. The maximum and minimum are 4096000000000000 and 4096000000000000.