百钱买百鸡:雄鸡7元1只,母鸡5元1只,小鸡1元3只,花百元钱百只鸡。如果雄鸡、母鸡、小鸡都必须有,则雄鸡、母鸡、小鸡应各买多少只?
#include <iostream>
using namespace std;
int main()
{
for(int c = 1; c <= 13; ++c)
{
for(int h = 1; h <= 18; ++h)
{
for(int s = 1; s <= 96; ++s)
{
if((c+h+s==100&&7*c+5*h+s/3==100)&&(s%3==0))
cout << "雄鸡:" << c << ", 母鸡:" << h << ", 小鸡:" << 100 - c - h << endl;
}
}
}
}