Esempio n. 1
0
        static void Main()
        {
            var records = new List <long>();

            while (true)
            {
                try
                {
                    using (var sc = new SetConsole())
                    {
                        var sw = new Stopwatch();
                        sw.Start();
                        Program.Main(null);
                        sw.Stop();
                        records.Add(sw.ElapsedMilliseconds);
                        sw.Reset();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.WriteLine("\n====================");
                    Console.WriteLine("Process was supended");
                    Console.WriteLine("====================\n");
                }
                if (records.Any())
                {
                    Console.WriteLine("\n====================");
                    Console.WriteLine($"Time is {records.Last()}ms");
                    Console.WriteLine($"AveTime is {records.Average()}ms");
                    Console.WriteLine("====================\n");
                }
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var abcdef         = GetArray <int>();
                var a              = abcdef[0];
                var b              = abcdef[1];
                var c              = abcdef[2];
                var d              = abcdef[3];
                var e              = abcdef[4];
                var limitedPercent = e * 100.0 / (e + 100);
                var f              = abcdef[5];

                var xs = new List <int>();
                var ys = new List <int>();
                for (int i = 0; i < f; i++)
                {
                    for (int j = 0; j < f; j++)
                    {
                        int x = a * 100 * i + b * 100 * j;
                        int y = c * i + d * j;
                        if (f >= x && x != 0)
                        {
                            xs.Add(x);
                        }
                        if (f > y)
                        {
                            ys.Add(y);
                        }
                    }
                }

                var pairs = new List <Tuple <int, int> >();
                foreach (var x in xs)
                {
                    foreach (var y in ys)
                    {
                        double percent = y * 100.0 / (x + y);
                        if (limitedPercent >= percent && f >= x + y)
                        {
                            pairs.Add(Tuple.Create(y, x));
                        }
                    }
                }
                var densitiest = pairs.Aggregate((acc, p) => (p.Item1 * 100.0 / (p.Item1 + p.Item2)) > acc.Item1 * 100.0 / (acc.Item1 + acc.Item2) ? p : acc);
                CWrite($"{densitiest.Item2 + densitiest.Item1} {densitiest.Item1}");
            }
        }