amhed
10/8/2013 - 3:10 AM

chefOdd.cs

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();
        }
    }
}