#B4213. Frog Rendezvous
Frog Rendezvous
Frog Rendezvous
Given a pond of length , two frogs start swimming simultaneously from opposite banks. The first frog starts at the left bank and swims to the right with constant speed , while the second frog starts at the right bank and swims to the left with constant speed . Whenever a frog reaches a bank, it instantly reverses direction and continues swimming at the same speed. In a total time of time units, determine the number of times the two frogs meet.
Note: Let . If is an integer and positive, then the answer is , otherwise it is . (Meetings exactly at time when both frogs reach the bank are not counted as a meeting.)
inputFormat
Input consists of a single line containing four space-separated positive numbers: , , , and .
outputFormat
Output a single integer representing the number of times the two frogs meet within time units.
sample
10 1 1 10
1