Http://blog.csdn.net/pipisorry/article/details/36433305
Problem description
The chicken and rabbit are closed in a cage (the chicken has two feet and the rabbit has four feet, no exception ). I already know the total number of feet in the cage. I asked how many animals are in the cage and how many animals are there at most.
Input
The first row is the number of N groups of test data, followed by N rows of input. Each group of test data occupies one row and each row has a positive integer a (A <32768)
Output
The output contains N rows. Each row corresponds to one input and contains two positive integers. The first is the minimum number of animals, and the second is the maximum number of animals. The two positive integers are separated by a space.
If no answer meets the requirements, two zeros are output.
Sample Input
2
3
20
Sample output
0 0
5 10
========================================================== ========================================================== =====
/*************************************** *************************************//* Poj Reading Notes 2.1 -- chicken and rabbit skins in the same cage *//************************** **************************************** * *********/# include <stdio. h> void cage () {int count; scanf ("% d", & COUNT); int A; while (count --) {scanf ("% d ", & A); if (a % 2) {// the odd number does not parse printf ("0 0 \ n");} else {printf ("% d \ n ", a/4 + A % 4/2, a/2); // minimum a/4 (the remaining a % 4/2 are chicken); Maximum A/2 (no rabbit )}}} void main () {cage ();}
From: http://blog.csdn.net/pipisorry/article/details/36433305