問題一覧 > 通常問題

No.604 Birthday Allowance

レベル : / AI推定難易度 : 850 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 246
作問者 : nmnmnmnmnmnmnm / テスター : kopricky
お気に入りにしたユーザー ProblemId : 1992 / 自分の提出
問題文最終更新日: 2026-07-01 20:00:03
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
Advent Calendar Contest 2017 (順位表) の他の問題:

Problem Statement

Starting from his 1st birthday, Yuki receives an allowance on his birthday every year.

・If his age on the birthday is not a multiple of $A$, he receives an allowance of 1 yen.
・If his age on the birthday is a multiple of $A$, he receives an allowance of $B$ yen.

On which birthday (at what age) does the total of his birthday allowances first reach $C$ yen or more?
Note that Yuki never dies.

Input

$A$ $B$ $C$

$A$, $B$, $C$ are positive integers.
$1 \le$ A,B,C $\le 1000000000000000000=10^{18}$.

Output

Output the answer on one line.
End the output with a newline.

Sample

Sample 1
Input
3 5 8
Output
4

On his 1st birthday, he receives 1 yen.
On his 2nd birthday, he receives 1 yen.
On his 3rd birthday, he receives 5 yen.
On his 4th birthday, he receives 1 yen.
At age 4, the total allowance has become 8 yen.
Since the total allowance has reached 8 yen or more, the answer is 4.

Sample 2
Input
2 2 8
Output
6

On his 1st birthday, he receives 1 yen.
On his 2nd birthday, he receives 2 yen.
On his 3rd birthday, he receives 1 yen.
On his 4th birthday, he receives 2 yen.
On his 5th birthday, he receives 1 yen.
On his 6th birthday, he receives 2 yen.
At age 6, the total allowance has become 9 yen.
Since the total allowance has reached 8 yen or more, the answer is 6.

Sample 3
Input
1000000000000000000 1000000000000000000 1000000000000000000
Output
1000000000000000000

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。