【Educational Codeforces Round 10A】【简单讨论】Gabriel and Caterpillar 白天爬a晚上落b多久爬出洞

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.


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template inline void gmin(T1 &a, T2 b) { if (b= h)
		{
			puts("0");
			continue;
		}
		h -= pre;
		if (day <= night)
		{
			puts("-1");
			continue;
		}
		int add = day - night;
		int ans = h / add + (h%add>0);
		printf("%d\n", ans);
	}
	return 0;
}
/*
【trick&&吐槽】
注意细节——
这里的判定是day<=night => puts("-1");
<=的=也非常关键,必不可少。

【题意】
很有趣的一道经典题。
要爬h的高度。白天+day 晚上-night。问多久才能爬出去

【类型】
简单讨论

【分析】
这题其实还有时刻性,即以小时为单位。
然而只要处理好第一天即可~~

【时间复杂度&&优化】
O(n)

*/


你可能感兴趣的:(题库-CF,CodeForces,水题,讨论)