+ 4

If there are m heads and n feet. How to write program to display no of cows and no of men found?

Sample input 1: 3 10 Sample output 1: Cows :2 Men :1 Sample input 2: 10 44 Sample output 2: Invalid input

4th Apr 2020, 6:07 AM
Roshini Balivada
3 odpowiedzi
+ 7
Cow=(n-2*m)/2; Men=m-(n-2*m)/2; After solving
4th Apr 2020, 6:18 AM
Puthur Harthik
+ 2
Hi Roshini I don't normally like to post a complete answer, but if you wish, there is an option here. https://code.sololearn.com/c2qtBl37cpV7/?ref=app
4th Apr 2020, 8:23 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
a=int(input()) b=int(input()) c=a d=0 if (b>(a*4)): print("in valid") elif(b==(a*4)): print("c:"+a) print("d:0") else: while(c>0): if(b<c*4): c=c-1 b-=2 d=d+1 else: if(b==c*4): break print(c) print(d)
17th Apr 2021, 8:42 AM
YADHULA KIRAN