[ACM]Q10365: Blocks

[ACM]Q10365: Blocks


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Q10365
{
    class Program
    {
        static private int times, n; static private bool ttof, ntof, tof;
        static private ArrayList lst = new ArrayList(); static private int[] iarr;
        static void Main(string[] args)
        {
            for (; ; )
            {
            labelt: Console.Write("times>>>");
                ttof = int.TryParse(Console.ReadLine(), out times);
                if (!ttof) goto labelt;
                iarr = new int[times]; int count = 0;
                while (count < times)
                {
                labeln: Console.Write("n>>>");
                    ntof = int.TryParse(Console.ReadLine(), out n);
                    if (!ntof) goto labeln;
                    for (int i = 1; i <= n; i++)
                    {
                        tof = false;
                        for (int j = 1; j <= i; j++)
                        {
                            if (i * j > n) break;
                            for (int k = 1; k <= j; k++)
                            {
                                if (i * j * k > n) break;
                                if (i * j * k == n)
                                {
                                    lst.Add(2 * (i * j + i * k + j * k));
                                    tof = true;
                                    break;
                                }
                            }
                            if (tof) break;
                        }
                    }
                    lst.Sort();
                    iarr[count] = (int)lst[0];
                    lst.Clear();
                    count++;
                }
                foreach (int obj in iarr) Console.WriteLine(obj);
            }
        }
    }
}