026 school recruit Zhenti exercise expression evaluation (NetEase)

Expression evaluation

Title Description
class today, Xiao Yi teacher taught how to calculate addition and multiplication, multiplication takes precedence over addition, if an operator but added brackets, then it is the highest priority. For example:
1 + 3 = 7 * 2
1 * (2 + 3) = 5
1 * 2 * 3 = 6
(1 + 2) * 3 = 9
now want you to help him Xiao Yi is calculated for a given number 3 a, b , c, add "+", "*", "(", ")" symbol, the maximum value that can be obtained between them.

Input Description :
a row of three numbers a, b, c (1 < = a, b, c <= 10)

Output Description :
maximum value that can be obtained

1 a,b,c = [int(x) for x in input().strip().split()]
2 maxval = 0
3 maxval = max(maxval,a+b+c)
4 maxval = max(maxval,a*b*c)
5 maxval = max(maxval,a+b*c)
6 maxval = max(maxval,(a+b)*c)
7 maxval = max(maxval,a*b+c)
8 maxval = max(maxval,a*(b+c))
9 print(maxval)

Algorithm thinking: exhaustive method.

 

Guess you like

Origin www.cnblogs.com/asenyang/p/11231248.html