<?php
$count = 0;
$amount = 600;
5000 => 200,
1000 => 0,
500 => 5,
100 => 0
);
foreach($bills as $faceValue => $quantity){
$count+= $faceValue * $quantity;
}
echo "Сумма: {$amount}\n";
if($amount % 100 != 0){
echo "Выдача невозможна : сумма не кратна 100\n";
}
elseif($amount < 0){
echo "Выдача невозможна : сумма меншье 0\n";
}
elseif($amount > $count){
echo "Выдача невозможна : в банкомате недостаточно купюр\n";
}
else{
echo "Выдача возможна, число купюр:\n";
foreach($bills as $faceValue => $quantity){
$abc = floor($amount / $faceValue); if($quantity == 0 || $amount < $faceValue){
}
elseif($abc <= $quantity){
$amount = $amount - ($abc * $faceValue);
echo "{$abc}x{$faceValue} ";
}
elseif($abc >= $quantity){
$amount = $amount - ($quantity * $faceValue);
echo "{$quantity}x{$faceValue} ";
}
}
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwokY291bnQgPSAwOwokYW1vdW50ID0gNjAwOwokYmlsbHMgPSBhcnJheSgKCTUwMDAgPT4gMjAwLAoJMTAwMCA9PiAwLAoJNTAwID0+IDUsCgkxMDAgPT4gMAopOwpmb3JlYWNoKCRiaWxscyBhcyAkZmFjZVZhbHVlID0+ICRxdWFudGl0eSl7CgkkY291bnQrPSAkZmFjZVZhbHVlICogJHF1YW50aXR5Owp9CmVjaG8gItCh0YPQvNC80LA6IHskYW1vdW50fVxuIjsKaWYoJGFtb3VudCAlIDEwMCAhPSAwKXsKCWVjaG8gItCS0YvQtNCw0YfQsCDQvdC10LLQvtC30LzQvtC20L3QsCA6INGB0YPQvNC80LAg0L3QtSDQutGA0LDRgtC90LAgMTAwXG4iOwp9CmVsc2VpZigkYW1vdW50IDwgMCl7CgllY2hvICLQktGL0LTQsNGH0LAg0L3QtdCy0L7Qt9C80L7QttC90LAgOiDRgdGD0LzQvNCwINC80LXQvdGI0YzQtSAwXG4iOwp9CmVsc2VpZigkYW1vdW50ID4gJGNvdW50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