Пример #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");
                }
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                long n        = long.Parse(GetString());
                long sum      = 0;
                var  divisors = new List <long>();

                for (long i = 1; i <= (long)Pow(n, 0.5); i++)
                {
                    if (n % i == 0)
                    {
                        divisors.Add(i);

                        if (i != n / i)
                        {
                            divisors.Add(n / i);
                        }
                    }
                }
                divisors.ForEach(d =>
                {
                    if (d - 1 == 0)
                    {
                        return;
                    }
                    if (n / (d - 1) != n % (d - 1))
                    {
                        return;
                    }
                    sum += d - 1;
                });

                CWrite(sum);
            }
        }