Title Details - Number Addition and Subtraction Game

Content

Number Addition and Subtraction Game

题目描述

Xiao Ming is playing a number addition and subtraction game, using only addition or subtraction to turn a number s into number t.

In each round, Xiaoming can add or subtract a number from the current number.

Now there are two numbers that can be used for addition and subtraction, namely a, b (a!=b), where b has no usage limit.

How many times can Xiao Ming use 'a' at least to change the number 's' into the number 't'.

The title ensures that number s can always be transformed into number t.

Input Description

The only line of input contains four positive integers s, t, a, b (1<=s,t,a,b<=10^5), and a!=b.

Output Description

The only line of output contains an integer, representing the minimum number of times 'a' needs to be used to turn number s into number t.

Test Case 1

1 10 5 2
1

The initial value of 1 is increased by a once to become 6, then increased by b twice to become 10, so the number of times a is used is 1

11 33 4 10
2

11 minus a twice becomes 3, then add b three times to become 33, so the number of times a is used is 2 times


Page 2


Page 3

Summary
The article discusses a number addition and subtraction game where a player needs to reach a target number using only addition or subtraction with two given numbers. The player can use one number without any limit and needs to minimize the usage of the other number to reach the target. The input consists of four positive integers: starting number s, target number t, and two different numbers a and b. The output should be the minimum number of times the player needs to use the number a to transform s into t. Two examples are provided: in the first example, starting from 1, the player needs to use a once to reach 6 and then use b twice to reach 10, so the answer is 1. In the second example, starting from 11, the player needs to use a twice to reach 3 and then use b three times to reach 33, so the answer is 2.