No.176 Two Kinds of Stamps
Problem Statement
In the Kingdom of Yuki, two kinds of postage stamps are issued: $A$-yen stamps and $B$-yen stamps.
By combining these two kinds of stamps well,
you are going to put stamps worth at least $T$ yen on a piece of mail,
but the total value of the stamps must be as small as possible.
When the total value of the stamps is minimized,
how many yen worth of stamps will you put on?
Answer that total value.
Note that you do not necessarily have to use both kinds of stamps,
and there is no limit on the number of stamps.
Input
$A$ $B$ $T$
$1 \le A < B \le 10^9$
$1 \le T \le 10^9$
$A$, $B$, $T$ are all integers.
Output
Output the total value of the stamps.
Sample
Sample 1
Input
50 80 120
Output
130
It is not possible to make exactly 120 yen by combining 50-yen stamps and 80-yen stamps.
In this case, using one 50-yen stamp and one 80-yen stamp to make 130 yen
gives the minimum amount that is at least 120 yen.
Sample 2
Input
123 456 1
Output
123
You do not necessarily have to use both kinds of stamps.
In this case, you will put on one 123-yen stamp, the one with the smaller face value.
Sample 3
Input
1234 1688 10000
Output
10000
It seems that, with a good combination, you can make exactly 10000 yen.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
tails