Hundred dollars in PHP to buy hundred chickens

Source: Internet
Author: User

<title> hundred money buy Hundred chicken </title>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>
<?php
/* Title: Rooster One, worth five, hen one, worth three, chicken three, worth one. Hundred money buys hundred chicken, asks the rooster, the hen, the chicken each geometry? */
$g: The number of cocks to buy
$m: The number of hens to buy
$x, number of chickens to buy
How many times $count =0;//statistics calculated
for ($g =0; $g <=100/5; $g + +)
{
for ($m =0; $m <33; $m + +)
{
$x =100-$g-$m;
if (5* $g +3* $m + $x/3==100 && $x%3==0)
{
echo "Can buy Rooster". $g. " Only "." can buy hens ". $m." Only "." can buy chickens ". $x." Only ";
}
$count + +;
}
echo "<br/>";
}
echo $count;//Number of calculations
?>

Note: The encoding of the file to be saved is consistent with the encoding of the setting, otherwise there will be garbled problems

Hundred dollars in PHP to buy hundred chickens

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.