#abc207b. B - Hydrate
B - Hydrate
Score : points
问题描述
有一个容器,其中装有 个青色球。Takahashi 将根据需要重复执行以下操作任意次数(可能为零次):
- 向容器中添加 个青色球和 个红色球。
Takahashi 的目标是达到一种状态,使得容器中青色球的数量最多是红色球数量的 倍。
确定该目标是否可以实现。如果目标可以实现,则找出实现目标所需的最少操作次数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a container with cyan balls. Takahashi will do the following operation as many times as he likes (possibly zero times):
- add cyan balls and red balls into the container.
Takahashi's objective is to reach a situation where the number of cyan balls in the container is at most times the number of red balls in it.
Determine whether the objective is achievable. If it is achievable, find the minimum number of operations needed to achieve it.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi's objective is achievable, print the minimum number of operations needed to achieve it. Otherwise, print -1
.
Sample Input 1
5 2 3 2
Sample Output 1
2
Before the first operation, the container has cyan balls and red balls. Since is greater than multiplied by , Takahashi's objective is not yet achieved.
Just after the first operation, the container has cyan balls and red balls. Since is greater than multiplied by , the objective is still not achieved.
Just after the second operation, the container has cyan balls and red balls. Since is not greater than multiplied by , the objective is achieved.
Thus, the answer is .
Sample Input 2
6 9 2 3
Sample Output 2
-1
No matter how many times Takahashi repeats the operation, his objective will never be achieved.
update @ 2024/3/10 09:20:09