Esempio n. 1
0
        static void Main(string[] args)
        {
            tests        tests         = new tests();
            StreamReader input_stream  = new StreamReader("input.txt");
            StreamWriter output_stream = new StreamWriter("output.txt");
            Stopwatch    stopWatch     = new Stopwatch();

            while (!input_stream.EndOfStream)
            {
                int          num_of_lines = Int32.Parse(input_stream.ReadLine());
                List <int[]> records      = new List <int[]>();
                int[]        temp;
                stopWatch.Restart();
                for (int i = 0; i < num_of_lines; i++)
                {
                    temp = new int[26];
                    foreach (char e in input_stream.ReadLine())
                    {
                        temp[((int)e) - 65]++;
                    }
                    if (records.Find(item => item.SequenceEqual(temp)) == null)
                    {
                        records.Add(temp);
                    }
                }
                output_stream.WriteLine(records.Count);
                output_stream.WriteLine(stopWatch.Elapsed);
            }
            input_stream.Close();
            output_stream.Close();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            tests        new_test      = new tests();
            StreamReader input_stream  = new StreamReader("input.txt");
            StreamWriter output_stream = new StreamWriter("output.txt");

            int N = 0, K, M, L;

            int[]     a;
            Stopwatch stopWatch = new Stopwatch();

            while (input_stream.EndOfStream == false)
            {
                string[] input = input_stream.ReadLine().Split(' ');
                N = Int32.Parse(input[0]); K = Int32.Parse(input[1]); M = Int32.Parse(input[2]); L = Int32.Parse(input[3]);
                Console.WriteLine("Current test:" + N);
                a    = new Int32[N];
                a[0] = K;
                for (UInt32 i = 0; i < N - 1; i++)
                {
                    a[i + 1] = (Int32)((a[i] * (long)M) & 0xFFFFFFFFU) % L;
                }
                stopWatch = new Stopwatch();
                QuickSort(a, 0, N - 1);
                stopWatch.Restart();
                output_stream.WriteLine(Summarize(a));
                stopWatch.Stop();
                output_stream.WriteLine(stopWatch.Elapsed);
            }
            input_stream.Close();
            output_stream.Close();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            double       starting_memory = (double)Process.GetCurrentProcess().WorkingSet64 / 1024 / 1024;
            tests        new_tests       = new tests();
            StreamReader input_stream    = new StreamReader("input.txt");
            StreamWriter output_stream   = new StreamWriter("output.txt");
            double       current_memory;

            string[]          lines;
            List <Milestones> milestones = new List <Milestones>();
            Stopwatch         stopWatch  = new Stopwatch();
            int N;

            while (!input_stream.EndOfStream)
            {
                milestones.Clear();
                N     = Int32.Parse(input_stream.ReadLine());
                lines = new string[N];
                for (int i = 0; i < N; i++)
                {
                    lines[i] = input_stream.ReadLine();
                }

                stopWatch.Restart();
                Array.Sort(lines);

                milestones.Add(new Milestones(0, '-'));
                for (int i = 1; i < N; i++)
                {
                    if (lines[i - 1][0] != lines[i][0])
                    {
                        milestones.Add(new Milestones(i, lines[i - 1][0]));
                    }
                }
                milestones.Add(new Milestones(N, lines[N - 1][0]));

                for (int i = 0; i < N; i++)
                {
                    findComponents(lines, i, lines[i], milestones, output_stream);
                }
                output_stream.WriteLine("Estimated time: " + stopWatch.Elapsed);
                current_memory = (double)Process.GetCurrentProcess().WorkingSet64 / 1024 / 1024;
                output_stream.WriteLine("Estimated memory: " + (current_memory - starting_memory) + " МB");
            }

            input_stream.Close();
            output_stream.Close();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //http://www.ega-math.narod.ru/Quant/Tickets.htm#A2
            tests        tests         = new tests();
            StreamReader input_stream  = new StreamReader("input.txt");
            StreamWriter output_stream = new StreamWriter("output.txt");
            Stopwatch    stopWatch     = new Stopwatch();

            int num_of_numbers, number_system;

            string[] input;

            while (!input_stream.EndOfStream)
            {
                input          = input_stream.ReadLine().Split(' ');
                num_of_numbers = Int32.Parse(input[0]); number_system = Int32.Parse(input[1]);
                stopWatch.Restart();
                output_stream.WriteLine(findLucky(num_of_numbers, number_system));
                output_stream.WriteLine(stopWatch.Elapsed);
            }

            input_stream.Close();
            output_stream.Close();
        }