SHARE
TWEET

01.Gift Coverage

MartinGeorgiev Jun 30th, 2019 (edited) 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $side = floatval(readline());
  3. $sheetCount = intval(readline());
  4. $coverPerSheet = floatval(readline());
  5.  
  6. $presentArea = pow($side, 2) * 6;
  7. $coverTotal = 0;
  8. while ($sheetCount > 0) {
  9.     if ($sheetCount % 3 == 0) {
  10.         $coverTotal += $coverPerSheet * 0.25;
  11.     } else {
  12.         $coverTotal += $coverPerSheet;
  13.  
  14.     }
  15.     $sheetCount--;
  16. }
  17. $percent = ($coverTotal / $presentArea) * 100;
  18. printf("You can cover %.2f%% of the box.", $percent);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top