FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)
Posted Annetree的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)相关的知识,希望对你有一定的参考价值。
Problem Description
Therearex frogs and y chicken in a garden. Kim found there are n heads and m legs in the garden. Please tell Kim how many frogs and chicken are there. (A frog has 4 legs, and a chicken has 2 legs.)
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: Two number n and m.
1<=n, m <=100000. The data is legal.
Output
For each test case, output two numbers A and B – the number of frog and the number of chicken.
Sample Input
2
2 6
2 4
Sample Output
1 1
0 2
1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 5 int main() 6 { 7 int T; 8 int n,m,a,b; 9 scanf("%d",&T); 10 while(T--) 11 { 12 scanf("%d%d",&n,&m); 13 a=(m-2*n)/2; 14 b=n-a; 15 printf("%d %d\n",a,b); 16 } 17 return 0; 18 }
以上是关于FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)的主要内容,如果未能解决你的问题,请参考以下文章