WOSS Dual Olympiad 2023 J2: 3 Numbers

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 1G

Authors:
Problem type

Pororo the penguin is playing with numbers! He is given 3 integers: A, B, and C. He can multiply or add the three numbers in any order, but he wants to get the largest possible result using all three numbers. For example, valid results are A \times (C + B), (C \times A) + B, or A + B + C. Help him figure out the largest possible result!

Constraints

-100 \leq A, B, C \leq 100

Input Specification

The first line contains 3 space-separated integers, A, B, and C.

Output Specification

Output a single integer, the largest result obtainable by multiplying and/or adding all 3 numbers in any order.

Sample Input 1

-1 3 5

Sample Output 1

14

Explanation of Sample 1

(3 \times 5) + (-1) = 14

Sample Input 2

-1 -3 5

Sample Output 2

15

Explanation of Sample 2

(-1) \times (-3) \times 5 = 15


Comments

There are no comments at the moment.