题目链接:

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
  1. 10 30
    2 1
output
  1. 1
input
  1. 10 13
    1 1
output
  1. 0
input
  1. 10 19
    1 2
output
  1. -1
input
  1. 1 50
    5 4
output
  1. 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代码:

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int h1,h2,a,b;
  6. scanf("%d%d",&h1,&h2);
  7. scanf("%d%d",&a,&b);
  8. h1+=*a;
  9. if(h1<h2&&a<=b)cout<<"-1"<<endl;
  10. else
  11. {
  12. int ans=;
  13. while()
  14. {
  15. if(h1>=h2)
  16. {
  17. cout<<ans<<endl;
  18. break;
  19. }
  20. h1-=*b;
  21. h1+=*a;
  22. ans++;
  23. }
  24.  
  25. }
  26.  
  27. return ;
  28. }

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. selenium驱动Firefox跳转页慢慢慢的问题(待验证)

    转载至http://www.cnblogs.com/yicaifeitian/p/5198871.html 为了解决这个问题,我是查了很多资料,解决方案是百度出来的.抱歉,我忘记出处在哪了,代码如下: ...

  2. python学习 01 变量

    1.变量不是‘盒子’. 1.1 不同的值,变量名没变,   变量地址也会变. 1.2 相同的值,不同的变量名,变量地址是相同的

  3. mysql ODBC连接配置

    1.软件包安装 [root@server1 mysql]# rpm -ivh MySQL-server-5.1.72-1.glibc23.i386.rpm [root@server1 mysql]# ...

  4. Entity Framework(1)——Connections and Models

    原文:https://msdn.microsoft.com/en-us/data/jj592674 应该选择CodeFirst.ModelFirst还是databaseFirst网上已经很多资料了,这 ...

  5. ASP.NET中指定自定义HTTP响应标头

    新建一个类HideServerHeaderHelper,继承 IHttpModule,然后重写 OnPreSendRequestHeaders,Dispose,Init方法,如下代码所示 using ...

  6. api 爬虫 避免相同 input 在信息未更新 情况下 重复请求重复

  7. PHP自定义函数: 下载远程文件

    function httpcopy($url, $file="", $timeout=60) { $file = empty($file) ? pathinfo($url,PATH ...

  8. NOIP考前划水

    NOIP考前划水 君指先跃动の光は.私の一生不変の信仰に.唯私の超電磁砲永世生き! 要开始背配置了? 3行不谢. (setq c-default-style "awk") (glo ...

  9. FPGA低温不能启动分析

    FPGA低温不能启动分析 现象描写叙述:在给medium板光端机做低温试验时,分别给发送版.接收板断电又一次启动,发现有的板子在-40°能够启动,而有些板子在-20°都不能启动.须要升高温度到0°以上 ...

  10. ACM-最小生成树之继续畅通project——hdu1879

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/lx417147512/article/details/27092583 ************** ...