問題一覧 > 通常問題

No.176 Two Kinds of Stamps

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 180
作問者 : 👑 tails
お気に入りにしたユーザー ProblemId : 457 / 自分の提出
問題文最終更新日: 2026-06-27 22:57:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 95 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。