Empty the Jug

Level pending

Imagine you have a jug with capacity $$x$$. You also have two glasses (glass 1 and glass 2) that have capacities $$a$$ and $$b$$, respectively. Initially, the jug is full of water, and the two glasses are empty. To transfer water, you can pour water from one container to another. However, you must continue to pour until either the pouring container is empty, or the receiving container is full. Note that all water you have is in the jug; you cannot get or throw away any water.

This file contains 100 different situations, where each situation is one line that has three space-seperated values: $$x$$, $$a$$, and $$b$$. For example, the line "20 1 4" would assign the value $$20$$ to $$x$$, the value $$1$$ to $$a$$, and the value $$4$$ to $$b$$.

For each situation, you transfer water among the buckets for a while, and you try to generate all possible arrangements of water placement where the jug is empty. Let the set $$A$$ represent all the possible amounts of water in glass 1 when the jug is empty, and let the set $$B$$ represent all the possible amounts of water in glass 2 when the jug is empty. The situation's diversity value is the number of elements in $$A$$ plus the number of elements in $$B$$.

For example, for the situation $$x = 10, a = 5, b = 8$$, the possible arrangements of water placement where the jug is empty (each in the form $$(a, b)$$) are $${(2, 8), (3, 7), (5, 5)}$$. Set $$A$$ would then be $$\{2, 3, 5\}$$, and set $$B$$ would be $$\{5, 7, 8\}$$. The situation's diversity value is therefore $$3 + 3 = \boxed{6}$$.

Find the sum of all the situations' diversity values in the file.

×