WC '17 Contest 2 J1 - The Rings of Power

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type
Woburn Challenge 2017-18 Round 2 - Junior Division

E Rings for the Elven-kings under the sky,
D for the Dwarf-lords in their halls of stone,
M for Mortal Men doomed to die,
One for the Dark Lord on his dark throne,
In the Land of Mordor where the Shadows lie,
One ring to rule them all, one ring to find them,
One ring to bring them all and in the darkness bind them,
In the Land of Mordor where the Shadows lie.

As the above passage indicates, a number of Rings of Power exist in Middle-earth, with exactly one of them owned by the Dark Lord Sauron, and the others distributed amongst Elves, Dwarves, and Men according to the values E, D, and M (2 \le E, D, M \le 9). Your task is to determine the total number of Rings of Power which have been forged (that is, the number of rings held by Elves, Dwarves, Men, and Sauron combined).

Input Specification

The first and only line of input consists of three space-separated integers, E, D, and M.

Output Specification

Output a single integer, the total number of Rings of Power.

Sample Input

3 7 9

Sample Output


Sample Explanation

Elves have 3 Rings, Dwarves have 7, Men have 9, and Sauron himself has 1, for a total of 20.


There are no comments at the moment.