取鸡蛋问题
2017-06-03 本文已影响0人
osi
$path = public_path('result.txt');
$not = [];
for ($i=1; $i < 99999; $i++) {
$rc = '';
if($i%63==0){
if($i%8==1){
if($i%5==4){
if($i%6==3){
$rc = "最终答案:".$i." \r\n";
$fp = fopen($path, 'a+');
fwrite($fp, $rc);
fclose($fp);
break;
}else{
$not[6][] = $i;
}
}else{
$not[5][] = $i;
}
}else{
$not[8][] = $i;
}
}else{
$not[63][] = $i;
}
}
$q=[
2=>'余1',
3=>'余0',
4=>'余1',
5=>'余4',
6=>'余3',
7=>'余0',
8=>'余1',
9=>'余0',
63=>'余0',
];
foreach ($not as $key => $value) {
$rc = '不满足 '.$key.'('.$q[$key].'):[';
$rc.=implode(',', $value);
$rc.="] \r\n";
$fp = fopen($path, 'a+');
fwrite($fp, $rc);
fclose($fp);
}