题库练习 Bus
← 上一题 下一题 →

A11214 | Bus

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

A bus moves along the coordinate line $Ox$ from the point $x=0$ to the point $x=a$ . After starting from the point $x=0$ , it reaches the point $x=a$ , immediately turns back and then moves to the point $x=0$ . After returning to the point $x=0$ it immediately goes back to the point $x=a$ and so on. Thus, the bus moves from $x=0$ to $x=a$ and back. Moving from the point $x=0$ to $x=a$ or from the point $x=a$ to $x=0$ is called a bus journey. In total, the bus must make $k$ journeys.

The petrol tank of the bus can hold $b$ liters of gasoline. To pass a single unit of distance the bus needs to spend exactly one liter of gasoline. The bus starts its first journey with a full petrol tank.

There is a gas station in point $x=f$ . This point is between points $x=0$ and $x=a$ . There are no other gas stations on the bus route. While passing by a gas station in either direction the bus can stop and completely refuel its tank. Thus, after stopping to refuel the tank will contain $b$ liters of gasoline.

What is the minimum number of times the bus needs to refuel at the point $x=f$ to make $k$ journeys? The first journey starts in the point $x=0$ .

输入格式

The first line contains four integers $a$ , $b$ , $f$ , $k$ ( $0<f<a<=10^{6}$ , $1<=b<=10^{9}$ , $1<=k<=10^{4}$ ) — the endpoint of the first bus journey, the capacity of the fuel tank of the bus, the point where the gas station is located, and the required number of journeys.

输出格式

Print the minimum number of times the bus needs to refuel to make $k$ journeys. If it is impossible for the bus to make $k$ journeys, print -1.

输入输出样例

输入 #1
6 9 2 4
输出 #1
4
输入 #2
6 10 2 4
输出 #2
2
输入 #3
6 5 4 3
输出 #3
-1
C++ 编辑器
输入
输出