Empty the Jug

Level pending

Imagine you have a jug with capacity x x . You also have two glasses (glass 1 and glass 2) that have capacities a a and b 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 x , a a , and b b . For example, the line "20 1 4" would assign the value 20 20 to x x , the value 1 1 to a a , and the value 4 4 to b 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 A represent all the possible amounts of water in glass 1 when the jug is empty, and let the set B 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 A plus the number of elements in B B .

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

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


The answer is 364.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...