Advertisement
Spocoman

01. Santa's Cookies

Feb 15th, 2024
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace SantasCookies
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int cup = 140,
  12.                 bigSpoon = 20,
  13.                 smallSpoon = 10,
  14.                 cookiesPerBox = 5,
  15.                 singleCookieGrams = 25,
  16.                 totalBoxes = 0,
  17.                 batches = int.Parse(Console.ReadLine());
  18.  
  19.             for (int b = 0; b < batches; b++)
  20.             {
  21.                 int flour = int.Parse(Console.ReadLine());
  22.                 int sugar = int.Parse(Console.ReadLine());
  23.                 int cocoa = int.Parse(Console.ReadLine());
  24.  
  25.                 int flourCups = flour / cup,
  26.                     sugarSpoons = sugar / bigSpoon,
  27.                     cocoaSpoons = cocoa / smallSpoon;
  28.  
  29.                 int boxesOfCookies = (cup + bigSpoon + smallSpoon)
  30.                     * new[] { flourCups, sugarSpoons, cocoaSpoons }.Min()
  31.                     / singleCookieGrams / cookiesPerBox;
  32.  
  33.                 if (boxesOfCookies == 0)
  34.                 {
  35.                     Console.WriteLine("Ingredients are not enough for a box of cookies.");
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine($"Boxes of cookies: {boxesOfCookies}");
  40.                     totalBoxes += boxesOfCookies;
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine($"Total boxes: {totalBoxes}");
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement