#B2614. Rabbits and Chickens Problem

    ID: 11253 Type: Default 1000ms 256MiB

Rabbits and Chickens Problem

Rabbits and Chickens Problem

There is a cage containing some rabbits and chickens. A rabbit has $4$ legs and a chicken has $2$ legs. Given that there are $h$ heads and $f$ legs, determine the number of rabbits and chickens by solving the equations:

$$4r + 2c = f, \quad r + c = h$$

Where $r$ is the number of rabbits and $c$ is the number of chickens. It is guaranteed that a valid solution exists.

inputFormat

The input consists of two integers separated by a space: the number of heads (h) and the number of legs (f).

outputFormat

Output two integers separated by a space: the number of rabbits and the number of chickens.

sample

35 94
12 23