In a zoo there are some birds and
animals. All birds have two legs and all animals have four legs. Given the head
count and leg count of both birds and animals taken together, the program must
print the head count of birds and animals separated by a space as output.
Input
Format:
First line will contain the integer
value H representing the head count of both birds and animals taken together.
Second line will contain the integer value L representing the leg count of both
birds and animals taken together.
Output
Format:
First line will contain the integer
values of the head count of birds and animals separated by a space.
Constraints: 0 < H <
1000 1 < L < 2000
Sample
Input/Output:
Example 1:
Input:
27
84
Output:
12 15
Explanation: There are 12 birds and 15
animals.
Solution-1:
h,l=int(input()),int(input())
print(h-(l-2*h)//2,(l-2*h)//2)
Solution-2:
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
int h,l;
cin>>h>>l;
cout<<h-(l-2*h)/2<<" "<<(l-2*h)/2;
}