Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $width = intval(readline());
- $length = intval(readline());
- $cake = $width * $length;
- $pieces = 0;
- while (true) {
- $piecesOfCake = intval(readline());
- $pieces += $piecesOfCake;
- if ($pieces >= $cake) {
- $pieces -= $cake;
- echo "No more cake left! You need $pieces pieces more.";
- break;
- }
- if ($piecesOfCake == "STOP") {
- $pieces -= $cake;
- printf("%d pieces are left.", abs($pieces));
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment