Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Juice_Diet
- {
- class Program
- {
- static void Main(string[] args)
- {
- int raspberry = int.Parse(Console.ReadLine());
- int strawberry = int.Parse(Console.ReadLine());
- int cherry = int.Parse(Console.ReadLine());
- int juiceLimit = int.Parse(Console.ReadLine());
- var total = 0.0;
- var maxMl = 0.0;
- for (var R = 0; R <= raspberry ; R++)
- {
- for (var S = 0; S <= strawberry ; S++)
- {
- for (var C = 0; C <= cherry; C++)
- {
- var raspML = R * 4.5;
- var strawML = S * 7.5;
- var cherryML = C * 15;
- total = raspML + strawML + cherryML;
- if (total <= juiceLimit)
- {
- if (total > maxMl)
- {
- maxMl = total;
- }
- }
- }
- }
- }
- for (var R = 0; R <= raspberry; R++)
- {
- for (var S = 0; S <= strawberry; S++)
- {
- for (var C = 0; C <= cherry; C++)
- {
- var raspML = R * 4.5;
- var strawML = S * 7.5;
- var cherryML = C * 15;
- total = raspML + strawML + cherryML;
- if (total == maxMl)
- {
- Console.WriteLine("{0} Raspberries, {1} Strawberries, {2} Cherries. Juice: {3} ml.", R, S, C, total);
- return;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement