LCC '25 Contest 2 J2 - Animal Pens

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

In the morning, farmer John does a count of all of the animals in his pen. His pens consist of only cows and chickens. For those of you who don't know, a cow has 4 legs, and a chicken has 2 legs.

John counts H heads and L legs total. Determine the number of cows and chickens.

Subtasks

1 \leq H,L \leq 10^9

Subtask 1 [30%]

1 \leq H,L \leq 10^3

Subtask 2 [70%]

No further subtasks.

Input Specifications

The first and only line will contain space-separated integers H and L.

Output Specifications

One one line, output the number of cows in the pens, followed by the number of chickens. It is guaranteed that there is an integer solution.

Sample Input

9 28

Sample Output

5 4

Explanation for Sample Output

With 5 cows and 4 chickens, there are 5 \times 4 + 4 \times 2 = 28 legs in total.


Comments

There are no comments at the moment.