Created
October 8, 2013 03:10
-
-
Save amhed/6878848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChefOdd { class Program { static void Main(string[] args) { var qty = Convert.ToInt32(Console.ReadLine()); var testCases = new int[qty]; for (var i = 0; i < qty; i++) { var input = Convert.ToInt32(Console.ReadLine()); testCases[i] = input; } for (var i = 0; i < qty; i++) { GetBestPlace(testCases[i]); } Console.Read(); } private static void GetBestPlace(int testCase) { var initArray = Enumerable.Range(1, testCase).ToArray(); Console.WriteLine(DrawArray(initArray)); while (initArray.Length > 1) { var newArrSize = initArray.Length/2; var newArr = new int[newArrSize]; for (var i = 0; i < newArrSize; i++) { newArr[i] = initArray[i*2 + 1]; } initArray = newArr; Console.WriteLine(DrawArray(initArray)); } } private static string DrawArray(int[] arr) { var sb = new System.Text.StringBuilder(); foreach (var t in arr) { sb.Append(t + " "); } return sb.ToString(); } } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment