码迷,mamicode.com
首页 > 其他好文 > 详细

FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)

时间:2017-07-24 11:43:59      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:space   ima   represent   code   inpu   test   esc   cst   line   

 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 第八届福建省赛 (鸡兔同笼水题)

标签:space   ima   represent   code   inpu   test   esc   cst   line   

原文地址:http://www.cnblogs.com/Annetree/p/7227425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!