Advertisement
ShadowEmbrace

Party Profit

Nov 4th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. $companions = intval(readline());
  4. $days = intval(readline());
  5.  
  6. $coins = 0;
  7.  
  8. for ($i = 1; $i <= $days; $i++) {
  9.     if ($i % 10 === 0) {
  10.         $companions -= 2;
  11.     }
  12.     if ($i % 15 === 0) {
  13.         $companions += 5;
  14.     }
  15.     if ($i % 3 === 0) {
  16.         $coins -= $companions * 3;
  17.     }
  18.     if ($i % 5 === 0) {
  19.         $coins += $companions * 20;
  20.         if ($i % 3 === 0) {
  21.             $coins -= $companions * 2;
  22.         }
  23.     }
  24.     $coins += 50;
  25.     $coins -= $companions * 2;
  26. }
  27. $coinsPerCompanion = floor($coins / $companions);
  28.  
  29. echo "$companions companions received $coinsPerCompanion coins each.";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement