百錢百雞的python算法?
for cock in range(1,20+1):
for hen in range(1,33+1):
for biddy in range(1,99+1):
if (5*cock+3*hen+biddy/3)==100:
if (cock+hen+biddy)==100:
if biddy%3==0:
print cock,hen,biddy你也沒給價格,這個解答是假設公雞5塊,母雞3塊,小雞3只1塊
百錢百雞的python算法?
for cock in range(1,20+1):
for hen in range(1,33+1):
for biddy in range(1,99+1):
if (5*cock+3*hen+biddy/3)==100:
if (cock+hen+biddy)==100:
if biddy%3==0:
print cock,hen,biddy你也沒給價格,這個解答是假設公雞5塊,母雞3塊,小雞3只1塊