2036 - C hicken and rabbit s
Chicken and rabbits are in a same cage. As we all know, chicken has two legs but rabbit has four. Now
we know the number of legs in the cage is A, please tell me how many animals may in the cage at least
and at most.
题目输入
The first line of the input contains the number of test cases in the file. Each test case that follows
consists of one lines. each case contains only one integer numbers A specifying the total legs in the
cage .
题目输出
For each test case, print a line contains the answer
输入/输出样例
题目输入
2 3 20
题目输出
0 0 5 10
C语言解答
#include<stdio.h> int main() { int n; scanf("%d",&n); while(n--) { int m; scanf("%d",&m); if(m%2!=0)printf("0 0\n"); else printf("%d %d\n",m/4+(m%4)/2,m/2); } return 0; }
C++解答
#include<stdio.h> int main() { int n ,T; scanf("%d",&n); while(n--) { scanf("%d",&T); if(T%2!=0) printf("0 0\n"); else { if( T % 4 == 0) printf("%d %d\n",T/4,T/2); else printf("%d %d\n",T/4+1,T/2); } } return 0; }