P1 - HSIUNG

View as PDF

Submit solution

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

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 overfilling?

Input Specification

The first line will contain A, B, C (1 \leq A, B \leq C \leq 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

10

Explanation 1

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

Sample Input 2

5 7 13

Sample Output 1

12

Explanation 2

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


Comments

There are no comments at the moment.