A10301 | Gabriel and Caterpillar
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The $9$ -th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height $h_{1}$ cm from the ground. On the height $h_{2}$ cm ( $h_{2}>h_{1}$ ) on the same tree hung an apple and the caterpillar was crawling to the apple.
Gabriel is interested when the caterpillar gets the apple. He noted that the caterpillar goes up by $a$ cm per hour by day and slips down by $b$ cm per hour by night.
In how many days Gabriel should return to the forest to see the caterpillar get the apple. You can consider that the day starts at $10$ am and finishes at $10$ pm. Gabriel's classes finish at $2$ pm. You can consider that Gabriel noticed the caterpillar just after the classes at $2$ pm.
Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.
Gabriel is interested when the caterpillar gets the apple. He noted that the caterpillar goes up by $a$ cm per hour by day and slips down by $b$ cm per hour by night.
In how many days Gabriel should return to the forest to see the caterpillar get the apple. You can consider that the day starts at $10$ am and finishes at $10$ pm. Gabriel's classes finish at $2$ pm. You can consider that Gabriel noticed the caterpillar just after the classes at $2$ pm.
Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.
输入格式
The first line contains two integers $h_{1},h_{2}$ ( $1<=h_{1}<h_{2}<=10^{5}$ ) — the heights of the position of the caterpillar and the apple in centimeters.
The second line contains two integers $a,b$ ( $1<=a,b<=10^{5}$ ) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.
The second line contains two integers $a,b$ ( $1<=a,b<=10^{5}$ ) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.
输出格式
Print the only integer $k$ — the number of days Gabriel should wait to return to the forest and see the caterpillar getting the apple.
If the caterpillar can't get the apple print the only integer $-1$ .
If the caterpillar can't get the apple print the only integer $-1$ .
输入输出样例
输入 #1
10 30 2 1
输出 #1
1
输入 #2
10 13 1 1
输出 #2
0
输入 #3
10 19 1 2
输出 #3
-1
输入 #4
1 50 5 4
输出 #4
1
In the first example at $10$ pm of the first day the caterpillar gets the height $26$ . At $10$ am of the next day it slips down to the height $14$ . And finally at $6$ pm of the same day the caterpillar gets the apple.
Note that in the last example the caterpillar was slipping down under the ground and getting the apple on the next day.
Note that in the last example the caterpillar was slipping down under the ground and getting the apple on the next day.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted