Advertisement
Spocoman

01. Santa's Cookies

Feb 15th, 2024 (edited)
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int cup = 140,
  8.         bigSpoon = 20,
  9.         smallSpoon = 10,
  10.         cookiesPerBox = 5,
  11.         singleCookieGrams = 25;
  12.  
  13.     int batches, flour, sugar, cocoa, totalBoxes = 0;
  14.     cin >> batches;
  15.  
  16.     for (int b = 0; b < batches; b++) {
  17.         cin >> flour >> sugar >> cocoa;
  18.  
  19.         int flourCups = flour / cup,
  20.             sugarSpoons = sugar / bigSpoon,
  21.             cocoaSpoons = cocoa / smallSpoon;
  22.  
  23.         int boxesOfCookies = (cup + bigSpoon + smallSpoon)
  24.             * min({ flourCups, sugarSpoons, cocoaSpoons })
  25.             / singleCookieGrams / cookiesPerBox;
  26.  
  27.         if (boxesOfCookies == 0) {
  28.             cout << "Ingredients are not enough for a box of cookies." << endl;
  29.         }
  30.         else {
  31.             cout << "Boxes of cookies: " << boxesOfCookies << endl;
  32.             totalBoxes += boxesOfCookies;
  33.         }
  34.     }
  35.  
  36.     cout << "Total boxes: " << totalBoxes << endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement