题目链接:

A. Gabriel and Caterpillar

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 h1 cm from the ground. On the height h2 cm (h2 > h1) 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 byb 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 2pm.

Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.

Input

The first line contains two integers h1, h2 (1 ≤ h1 < h2 ≤ 105) — the heights of the position of the caterpillar and the apple in centimeters.

The second line contains two integers a, b (1 ≤ a, b ≤ 105) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.

Output

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.

Examples
input
10 30
2 1
output
1
input
10 13
1 1
output
0
input
10 19
1 2
output
-1
input
1 50
5 4
output
1
Note

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.

AC代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
int h1,h2,a,b;
scanf("%d%d",&h1,&h2);
scanf("%d%d",&a,&b);
h1+=*a;
if(h1<h2&&a<=b)cout<<"-1"<<endl;
else
{
int ans=;
while()
{
if(h1>=h2)
{
cout<<ans<<endl;
break;
}
h1-=*b;
h1+=*a;
ans++;
} } return ;
}

最新文章

  1. 20161106PM-接口
  2. NOIp 2013 #1 积木大赛 Label:有趣的模拟
  3. Python笔记——break的注意事项
  4. 【poj3608】 Bridge Across Islands
  5. php--group_concat()函数总结
  6. C++Primer 第九章
  7. C语言快速排序
  8. 基于ASP.Net +easyUI框架上传图片,实现图片上传,提交表单
  9. 【Python】python-一个class继承的小case
  10. html打印表格每页都有的表头和打印分页
  11. 用Less循环生成样式
  12. 游戏基础元素之精灵——Cocos2d-x学习历程(九)
  13. Cookies与保持登录(新浪微博的简单模拟登录)
  14. MySQL(3)-索引
  15. glusterfs 4.0.1 api 分析笔记1
  16. Scrapy爬取豆瓣电影top250的电影数据、海报,MySQL存储
  17. [SCOI2016]萌萌哒
  18. Hexo+Github博客最简教程-Dockerfile自动搭建
  19. Unity NavMesh导航网格 初级教程
  20. (转+整理)C#中使用GUID

热门文章

  1. 全文检索引擎Solr的配置
  2. Muduo网络库源代码分析(四)EventLoopThread和EventLoopThreadPool的封装
  3. ubuntu问题: 同时只能有一个软件管理工具在运行
  4. netbeans无法新建项目
  5. python(pytest)+allure+jenkins 实现接口自动化的思路
  6. cookie的坑
  7. 【题解】POJ2279 Mr.Young′s Picture Permutations dp
  8. Centos设置开机启动Apache和Mysql
  9. HDU 4772 Zhuge Liang&amp;#39;s Password (简单模拟题)
  10. 又一次发现Oracle太美之awr相关脚本简介