#C1335. Exact Leg Count Problem
Exact Leg Count Problem
Exact Leg Count Problem
You are given a single non-negative integer L representing the total number of legs that must be present on a farm. On this farm, there are chickens and cows. Each chicken has 2 legs and each cow has 4 legs.
Your task is to determine if it is possible to have exactly L legs by choosing a non-negative number of chickens and cows. If it is possible, output YES
on the first line, and on the second line output two non-negative integers, the number of chickens and the number of cows respectively, that satisfy the equation:
\(2c + 4w = L\)
If it is not possible to achieve exactly L legs, output NO
.
Note: In this problem, you only need to output one valid pair (chickens, cows) if the solution exists. It is acceptable to output the configuration where all legs come from chickens (i.e. cows = 0) when L is even.
inputFormat
The input consists of a single integer L (0 ≤ L ≤ 10^9
), read from standard input.
outputFormat
If it is possible to have exactly L legs, output YES
on the first line and then output two integers (number of chickens and number of cows) separated by a space on the second line. Otherwise, print NO
on a single line. The output should be written to standard output.
5
NO
</p>