http://blog.csdn.net/pipisorry/article/details/36433305
Descriptive narrative of the problem
A cage is closed with chickens and rabbits (chickens have 2 feet only.) The rabbit has 4 feet only. No exceptions).
Already know the total number of feet inside the cage a. Ask at least how many animals there are in a cage, and at most, just animals.
Input
The 1th line is the number of group N of the test data, followed by the N line input. Each group of test data accounted for 1 rows. One positive integer per line A (a < 32768)
Output
The output includes n rows, one input per line, and two positive integers. The first is the fewest number of animals. The second is the largest number of animals, two positive integers separated by a space
Suppose the answer is not met. The output is two x 0.
Example input
2
3
20
Example output
0 0
5 10
=====================================================================================
CODE:
/****************************************************************************//* POJ reading notes 2.1--chicken rabbit with cage skin 2014-7-2*//* /#include <stdio.h>void cage () { int count;scanf ("%d", &count), int a;while (count--) {scanf ("%d", &a), if (a%2) {//Odd no-solution printf ("0 0\n");} else{printf ("%d%d\n", A/4+A%4/2, A/2);//Least A/4 (the remaining a%4/2 are chickens); up to A/2 (no rabbits)}}}void main () {Cage ();}
from:http://blog.csdn.net/pipisorry/article/details/36433305
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
POJ reading notes 2.1--chicken rabbit cage Belt