Few more challenges on ProjectEuler
This commit is contained in:
34
ProjectEuler/031/problem31.php
Normal file
34
ProjectEuler/031/problem31.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
define("TOTAL", 200);
|
||||
$combo=0;
|
||||
$sum = 200;
|
||||
|
||||
for ($a = 0; $a <= (TOTAL / 200); $a++) {
|
||||
$sum_a = TOTAL - ($a * 200);
|
||||
for ($b = 0; $b <= ($sum_a / 100); $b++) {
|
||||
$sum_b = $sum_a - ($b * 100);
|
||||
for ($c = 0; $c <= ($sum_b / 50); $c++) {
|
||||
$sum_c = $sum_b - ($c * 50);
|
||||
for ($d = 0; $d <= ($sum_c / 20); $d++) {
|
||||
$sum_d = $sum_c - ($d * 20);
|
||||
for ($e = 0; $e <= ($sum_d / 10); $e++) {
|
||||
$sum_e = $sum_d - ($e * 10);
|
||||
for ($f = 0; $f <= ($sum_e / 5); $f++) {
|
||||
$sum_f = $sum_e - ($f * 5);
|
||||
for ($g = 0; $g <= ($sum_e / 2); $g++) {
|
||||
$sum_g = $sum_f - ($g * 2);
|
||||
for ($h = 0; $h <= ($sum_g / 1); $h++) {
|
||||
|
||||
if ($a * 200 + $b * 100 + $c * 50 + $d * 20 + $e * 10 + $f * 5 + $g * 2 + $h == TOTAL) {
|
||||
$combo++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo $combo;
|
Reference in New Issue
Block a user