Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2.  
  3. $days = intval(readline());
  4. $players = intval(readline());
  5. $energyGroup = floatval(readline());
  6. $waterPerson = floatval(readline());
  7. $foodPerson = floatval(readline());
  8.  
  9.  
  10.  
  11. $totalWater = $waterPerson * $days * $players;
  12. $totalFood = $foodPerson * $days * $players;
  13. $temp = 0;
  14. $boost = 0;
  15.  
  16.  
  17.  
  18.  
  19. for ($i = 1; $i <= $days; $i++) {
  20.     $energyLoss = floatval(readline());
  21.     $energyGroup -= $energyLoss;
  22.  
  23.     if ($energyGroup <= 0) {
  24.       break;
  25.     }
  26.  
  27.     if ($i % 3 == 0) {
  28.         $energyGroup *= 1.1;
  29.         $temp = $totalFood / $players;
  30.         $totalFood -= $temp;
  31.     }
  32.     if ($i % 2 == 0) {
  33.         $energyGroup *= 1.05;
  34.         $totalWater *= 0.7;
  35.     }
  36. }
  37.  
  38. if ($energyGroup <= 0) {
  39.     $totalFood= number_format($totalFood, 2);
  40.     $totalWater = number_format($totalWater, 2);
  41.     echo "You will run out of energy. You will be left with $totalFood food and $totalWater water.";
  42. } else {
  43.     printf("You are ready for the quest. You will be left with - %.2f energy!", $energyGroup);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement