百鸡问题 题解:C穷举
#include <stdio.h>
int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
int x,y,z;
for(x = 0; x <= 100; x++)
for(y = 0 ; y <= 100; y++)
for(z = 0; z <= 100; z++)
if(x*5+y*3+z*(float)(1.0/3.0) <= n && x+y+z == 100)
printf("x=%d,y=%d,z=%d\n",x,y,z);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发