#B2006. Sustainable Population Calculation

    ID: 11088 Type: Default 1000ms 256MiB

Sustainable Population Calculation

Sustainable Population Calculation

Assume that new resources on Earth grow at a constant rate. Based on this, the total available resources (current resources plus the newly generated ones) can support x billion people for a years, or y billion people for b years. In order to achieve sustainable development and avoid resource depletion, determine the maximum number of billions of people that Earth can support indefinitely.

Hint: Let the current resources be R₀ and the annual resource generation be r. Then the total resources available for a years is \[ R₀ + r \times a = x \times a, \] and for b years is \[ R₀ + r \times b = y \times b. \] Subtracting the two equations, you can solve for r as \[ r = \frac{y\,b - x\,a}{b - a}. \] Since for sustainable development the new resource production r must equal the annual consumption, the maximum sustainable population is equal to r (in billions).

inputFormat

The input consists of four numbers separated by spaces: x a y b.

Here, x and y (in billions) denote the population that can be supported for a years and b years, respectively.

outputFormat

Output a single number which represents the maximum sustainable population (in billions) that the Earth can support indefinitely. If the result is an integer, you may output it without a decimal point.

sample

2 4 3 6
5