百鸡问题C++
#include<iostream>
using namespace std;
int main()
{
int n,x, y, z;
cin >> n;
for(x=0;x<=100;x++)
for(y=0;y<=100;y++)
for (z = 0; z <= 100; z++)
{
if (x + y + z == 100 && 5 * x + 3 * y + z/3 == n&&z%%3==0)
cout << "x=" << x <<"," << "y=" << y << "," << "z=" << z << '
';
}
return 0;
}
推荐阅读