Woburn Challenge 2002
Problem 7: Old MacDonald's Farm
It seems as though the monkeys are really getting their act together. The Head-Monkey, with the help of the Big-White Monkey, managed to commandeer a Flowers By Irene truck, gaining access to the finest spy equipment the NSA can develop. Armed with these tools, the Head-Monkey's loyal minion, Tiny, snuck into Bo Vine's complex and overheard his plan to use the dreaded APE on the monkeys. The Head-Monkey, upon hearing these shocking developments, was compelled to enlist the services of her trusty friends, the apes, bison, parrots and three-eyed fish, of Old MacDonald's Farm, of course. You see, Old MacDonald and the Head-Monkey go back many years, but that's a story for another day. There seems to be a problem, however. The Head-Monkey has counted the total number of heads, feet, tails and eyes that there are, but she can't keep the collection of animals still for long enough to count exactly how many of each type there are! The Head-Monkey knows the following:
- Each animal has one head!
- An ape has two feet, two eyes, and no tail.
- A bison has four feet, two eyes, and one tail.
- A parrot has two feet, one eye (it's a pirate's bird, and it has an eye patch) and a tail.
- A three-eyed fish has zero feet, three eyes (…) and one tail.
InputThe first line of input contains a single integer, T (1 ≤ T ≤ 50), indicating the number of test cases.
Each test case consists of four integers, indicating the number of heads, feet, eyes and tails.
Note that these integers will be less than 215.
OutputThe number of apes, bison, parrots and fish, in that order, separated by a space.
If the values you obtain indicate fractional animals, or worse, negative animals, output "FUNNY FARM"!
3 10 16 21 9 10 24 19 6 11 25 20 6
1 2 3 4 4 3 2 1 FUNNY FARM
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 30, 2008
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3