3_6搬砖问题
Time Limit:1000MS Memory Limit:65536K
Total Submit:7707 Accepted:2916
Description
某工地需要搬运砖块,已知男人一人搬3块,女人一人搬2块,小孩两人搬1块,有多少种搬法用45人正好搬45块砖?
Input
无
Output
men= women= child=
Sample Input
无
Sample Output
men=0 women=15 child=30
men=3 women=10 child=32
men=6 women=5 child=34
men=9 women=0 child=36
Source
#include<stdio.h>
int main()
{
int x, y, z;
for (x = 0; x <= 45; x++)
{
for (y = 0; y <= 45; y++)
{
for (z = 0; z <= 45; z++)
{
if (3 * x + 2 * y + z / 2.0 == 45 && x + y + z == 45)
printf("men=%d women=%d child=%d\n", x, y, z);
}
}
}
return 0;
}