题目链接:

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 ;
}

codeforces 652A A. Gabriel and Caterpillar(水题)的更多相关文章

  1. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  2. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  3. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  4. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  5. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  6. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

  7. Codeforces - 1194B - Yet Another Crosses Problem - 水题

    https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...

  8. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  9. CodeForces 686A Free Ice Cream (水题模拟)

    题意:给定初始数量的冰激凌,然后n个操作,如果是“+”,那么数量就会增加,如果是“-”,如果现有的数量大于等于要减的数量,那么就减掉,如果小于, 那么孩子就会离家.问你最后剩下多少冰激凌,和出走的孩子 ...

随机推荐

  1. FreeSWITCH版本更新

    [1]FreeSWITCH版本更新 从2014年10月底开始,FreeSWITCH代码库改为由stash管理,该管理工具能更好地与jira集成. 如果你以前已经clone了代码,请做如下更新: git ...

  2. Call to static DateFormat

    Bug: Call to method of static java.text.DateFormatPattern id: STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INS ...

  3. 解决Discuz安装时报错“该函数需要 php.ini 中 allow_url_fopen 选项开启…”

    开启php的fsockopen函数 —— 解决DZ论坛安装问题“该函数需要 php.ini 中 allow_url_fopen 选项开启.请联系空间商,确定开启了此项功能 在安装dz论坛时遇到因为fs ...

  4. ios错误ignoring file xxx missing required architecture x86_64 in file

    错误ignoring file xxx missing required architecture x86_64 in file 解决方法: 1.在Project target里“Architectu ...

  5. C语言基础知识【循环】

    C 循环1.有的时候,我们可能需要多次执行同一块代码.一般情况下,语句是按顺序执行的:函数中的第一个语句先执行,接着是第二个语句,依此类推.编程语言提供了更为复杂执行路径的多种控制结构.循环语句允许我 ...

  6. Laravel开发:Laravel核心——服务容器的细节特性

    前言 在前面几个博客中,我详细讲了 Ioc 容器各个功能的使用.绑定的源码.解析的源码,今天这篇博客会详细介绍 Ioc 容器的一些细节,一些特性,以便更好地掌握容器的功能. 注:本文使用的测试类与测试 ...

  7. github-readme.md-格式

    大标题 大标题一般显示project名,类似html的<h1> 你仅仅要在标题以下跟上=====就可以 中标题 中标题一般显示重点项,类似html的<h2> 你仅仅要在标题以下 ...

  8. hdu 5381 The sum of gcd 2015多校联合训练赛#8莫队算法

    The sum of gcd Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  9. 设置tableView背景颜色

    [treeTableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight] ...

  10. python 基础 9.10 删除数据

      #/usr/bin/python #-*- coding:utf-8 -*- #@Time   :2017/11/24 4:40 #@Auther :liuzhenchuan #@File   : ...