Richmond Green P1 - HSIUNG

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type

Bill never works or does anything productive in Mr.Hsiung's class. So, Mr.Hsiung orders him to fill up his water bottle, with a capacity of C liters. Bill wants to delay this as much as possible, so he decides to fill Mr.Hsiung's bottle with 2 smaller bottles with capacity A and B. He can't fill Mr.Hsiung's bottle directly, but he can fill either of his 2 bottles full, and then dump all of its contents into Mr.Hsiung's bottle as many times as he wants. Of course, Bill cannot overflow Mr.Hsiung's bottle. Can you help him find the maximum amount Mr.Hsiung's bottle can be filled without overflowing?

Input Specification

The first line will contain A, B, C (1 \le A, B \le C \le 1000) each separated by a space.

Output Specification

Output the maximum amount of water Mr.Hsiung's bottle can contain when Bill fills them.

Sample Input 1

3 2 10

Sample Output 1


Explanation 1

In this case, the entire bottle can be filled by using the second bottle 5 times.

Sample Input 2

5 7 13

Sample Output 2


Explanation 2

In this case, Bill can use both bottles once to fill Mr.Hsiung's bottle up to 12 liters.


There are no comments at the moment.