Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace classwork2
- {
- class Program
- {
- static void Main()
- {
- var ropesInput = new double[] { 9, 13, 5, 8 };
- var maxlens = MaxNumber(ropesInput);
- var numberRopesCut = double.Parse(Console.ReadLine());
- for (var lenCutRopes = maxlens; lenCutRopes >= 1; lenCutRopes--)
- {
- int countCutRopes = 0;
- foreach (double rope in ropesInput)
- countCutRopes += (int)(numberRopesCut / lenCutRopes);
- if (countCutRopes >= numberRopesCut)
- {
- Console.WriteLine(lenCutRopes);
- break;
- }
- }
- }
- public static double MaxNumber(double[] array)
- {
- double maxNumb = 0;
- foreach (var numb in array)
- maxNumb = Math.Max(maxNumb, numb);
- return maxNumb;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement