Head Count - Birds and Animals
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.
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.
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.
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
0 < H < 1000
1 < L < 2000
Sample Input/Output:
Example 1:
Input:
27
84
Input:
27
84
Output:
12 15
12 15
Explanation:
There are 12 birds and 15 animals.
There are 12 birds and 15 animals.
Example 2:
Input:
114
256
Input:
114
256
Output:
100 14
100 14
Explanation:
There are 100 birds and 14 animals.
There are 100 birds and 14 animals.
C program:
#include<stdio.h>
#include <stdlib.h>
int main()
{
int h,l;
scanf("%d%d",&h,&l);
int a=l/2-h;
printf("%d %d",h-a,a);
}
for writing the program in python:
ReplyDeletehead=int(input())
legs=int(input())
animals=int(legs/2)-head
birds=head-animals
print(birds,animals)
instead of int(legs/2) ...use legs//2
Deletenice bro
ReplyDeleteSuperb bro
ReplyDeleteCasinos in Las Vegas - DRMCD
ReplyDeleteA full list of 공주 출장안마 all casinos in Las 군산 출장안마 Vegas: Casinos in 거제 출장마사지 Las Vegas, Las Vegas, Nevada, Nevada. 원주 출장샵 Use our list to 안동 출장샵 filter by casino type.