Algorithm Analysis:
1316, it is obvious that 1300 is a multiple of 13, but 16 is not a multiple of 11, you can think of any number from 1300 to subtract n 13 multiples of its result is still a multiple of 13, so long as 16 plus this minus n 13 multiples of its and is a multiple of 11, the answer may be more than one, But we just have to ask for a couple of solutions.
Careful observation is not difficult to find: (16+13*3) + (1300-13*3) = 1316, but we need to implement the code:
Copy CodeThe code is as follows:
$n = 1316;
$i =0;//minus the nth 13, initialized to 0
$y =16+13* $i,//1316 16 plus n 13, which is initialized to 16.
while ($y%11!=0) {//if 16 plus n 13 and not divisible by 11
$i ++;//plus another 13.
$y =16+13* $i;
}
echo ' $x = '. ($n-$y). '
';
echo ' $y = '. $y;
?>
http://www.bkjia.com/PHPjc/323644.html www.bkjia.com true http://www.bkjia.com/PHPjc/323644.html techarticle algorithm Analysis: 1316, it is obvious that 1300 is a multiple of 13, but 16 is not a multiple of 11, you can think of 1300 from any of the multiples of n 13 is the result is still a multiple of 13, then as long as 16 plus this minus ...