题解 | #百鸡问题#
百鸡问题
http://www.nowcoder.com/practice/01d161052db64c249a47fc723b4fd5db
#include <stdio.h>
int main()
{
int n;
int x, y ,z;
scanf("%d", &n);
for (x = 0; x <= 100; x ++)
for (y = 0; y <= 100; y++)
{
if (x + y > 100) continue;
for (z = 0; z <= 100; z++)
{
if(x + y + z > 100) continue;
if( x + y + z == 100 && 15 * x + 9 * y + z <= 3 * n)
printf("x=%d,y=%d,z=%d\n",x , y, z);
}
}
}