Aliendreamer

scalefocusFlourist

Nov 24th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace scaleFocus
  4. {
  5.    
  6.     using System.Linq;
  7.  
  8.     public class Program
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             int[] bouquetsNums = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.             int p = int.Parse(Console.ReadLine());
  14.  
  15.             int leftover = 0;
  16.             bool finished = false;
  17.  
  18.             int roses = 0;
  19.  
  20.             while (!finished)
  21.             {
  22.                 foreach (var t in bouquetsNums)
  23.                 {
  24.                     leftover++;
  25.  
  26.                     roses += t;
  27.                 }
  28.  
  29.                 roses += p;
  30.                 if (leftover >= p)
  31.                 {
  32.                     leftover -= p;
  33.                     roses += p;
  34.                 }
  35.  
  36.                 finished = leftover == 0;
  37.             }
  38.  
  39.             Console.WriteLine(roses);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment