能力值:
( LV2,RANK:10 )
|
-
-
|
能力值:
( LV2,RANK:10 )
|
-
-
|
能力值:
( LV2,RANK:10 )
|
-
-
[求助]百鸡问题
这个数学解法,应当看线性代数:多元方程的求解。
楼上两位都出了程序的暴力解法了,我也来段代码吧。
#include<stdio.h>
int main()
{
int iDa, iMu, iXiao;
int i;
for(iDa=1; iDa<20; iDa++)
{
for(iMu=1; iMu<33; iMu++)
{
for(iXiao=3; iXiao<100; iXiao+=3)
{
if( (100==(iDa+iMu+iXiao)) && (100==(iDa*5+iMu*3+iXiao/3)) )
{
printf("大公鸡:%d只,母鸡:%d只,小鸡:%d只\n", iDa, iMu, iXiao);
}
}
}
}
return 0;
}
|