<?php
//百牛百钱 公牛5文一只,母牛3文一只,小牛1文3只
//一百只牛刚好100文钱
//正常思维 x+y+z=100 5x+3y+1/3z=100;
//代码逻辑 枚举法 6数字 000000-999999
//公牛数量0-100 母牛0-100 小***0-100
//公牛$x只 ,母牛$Y只,小牛$z只
header("Content-type:text/html;charset=utf-8;");
for($x=0;$x<=100;$x++){
for($y=0;$y<=100;$y++){
for($z=0;$z<=100;$z++){
if(($x+$y+$z==100)&&($x*5+$y*3+$z/3==100)){
echo "公牛{$x}只,母牛{$y}只,小牛{$z}只<br />";
}
}
}
}
?>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!