2068:【例2.6】鸡兔同笼(2068: [example 2.6] chicken and rabbit in the same cage)

【题目描述】

数学中经典的“鸡兔同笼”问题,已知头共x个,脚共y只,问笼中的鸡和兔各有多少只?

【输入】

头和脚的数量。

【输出】

鸡和兔各自数量。一个空格隔开。

【输入样例】

30 90

【输出样例】

15 15
#include<iostream>
using namespace std;
int main()
{
    int x,y,j,t;
    cin>>x>>y;
    t=y/2-x;
    j=x-t;
    cout<<j<<" "<<t;
}
————————

[Title Description]

In the classic “chicken and rabbit in the same cage” problem in mathematics, it is known that there are x heads and Y feet. How many chickens and rabbits are there in the cage?

[input]

Number of heads and feet.

[output]

The number of chickens and rabbits. Separated by a space.

[input example]

30 90

[output example]

15 15
#include<iostream>
using namespace std;
int main()
{
    int x,y,j,t;
    cin>>x>>y;
    t=y/2-x;
    j=x-t;
    cout<<j<<" "<<t;
}