@underbottom/

smart ATM

PHP (Legacy)

No description

fork
loading
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

error_reporting(-1);

$amount = 6600;

$bills = [
    100 => 0,
    200 => 3,
    500 => 1,
    1000 => 0,
    2000 => 4,
    5000 => 1
];


for ($count5000 = 0; $bills[5000] >= $count5000 ; $count5000++) {
    for ($count2000 = 0; $bills[2000] >= $count2000 ; $count2000++) {
        for ($count1000 = 0; $bills[1000] >= $count1000 ; $count1000++) {
            for ($count500 = 0; $bills[500] >= $count500 ; $count500++) {
                for ($count200 = 0; $bills[200] >= $count200 ; $count200++) {
                    for ($count100 = 0; $bills[100] >= $count100 ; $count100++) {
                       if ($count100*100+$count200*200+$count500*500+$count1000*1000+$count2000*2000+$count5000*5000 == $amount) {
                         echo "Выдача возможна, число купюр:\n{$count100}x100 {$count200}x200 {$count500}x500 {$count1000}x1000 {$count2000}x2000 {$count5000}x5000\n";
                         exit();
                       }
                    }
                }
            }
        }
    }
}

echo "Выдача невозможна: недостаточно купюр.\n";


?>
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7