POJ reading notes 2.1--chicken rabbit cage Belt

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.