#!/usr/bin/python
#coding=utf-8
#for buy chicks
print '公雞5元一只,母雞3元一只,小雞一元3只,百錢買百雞有以下方案'
cocks=100//5
hens=100//3
chicks=100*3
for i in range(0,cocks+1):
for j in range(0,hens+1):
for k in range(0,chicks,3):
sum=i+j+k
total=5*i+3*j+int(k/3)
if sum==100 and int(total)==100:
print '公雞:'+str(i)+'\t' +'母雞:'+str(j)+'\t'+'小雞:'+str(k)
結果如下: