鸡和兔子一共35只,一共94只脚
穷举: 时间复杂度O(n)
for (int x=0;x<=35;x++){
int c=35-x;
if (x*4+c*2==94){
System.out.println("rabbit:"+c+",,,,Chicken:"+x);
}
}
最优解 时间复杂度O(1)
x+y=35;
2x+4y=94
int head=35;
int foot=94;
int rabbit=(foot-2*head)/2;
int chicken=head-rabbit;
System.out.println("兔子有"+rabbit+"只,,,鸡有"+chicken+"只");