Chongqing University of Posts and Telecommunications Python Homework 1. Chicken and Rabbit in the same cage ---- (the fourth homework)

Article Directory


Original title

Insert picture description here


Code

a,b = map(int,input().split())
flag = 0
for i in range(a+1):
    if i*2 + (a-i)*4 == b:
        flag = 1
        ret = i
        break
if flag == 1 : print("{} {}".format(ret,a-ret))
else:print("Data Error!")

Guess you like

Origin blog.csdn.net/qq_37500516/article/details/115237742