Exemplo n.º 1
0
        static void Main()
        {
            var kids   = Console.ReadLine().Split(' ');
            int number = int.Parse(Console.ReadLine());
            var queue  = new Queue <string>(kids);

            int cycle = 1;

            while (queue.Count > 1)
            {
                for (int cnt = 1; cnt < number; cnt++)
                {
                    string kid = queue.Dequeue();
                    queue.Enqueue(kid);
                }

                if (PrimeTool.IsPrime(cycle))
                {
                    Console.WriteLine($"Prime {queue.Peek()}");
                }
                else
                {
                    string removed = queue.Dequeue();
                    Console.WriteLine($"Removed {removed}");
                }

                cycle++;
            }

            var lastChild = queue.Dequeue();

            Console.WriteLine($"Last is {lastChild}");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var queue = new Queue <string>(input);
            var num   = int.Parse(Console.ReadLine());
            int cycle = 1;

            while (queue.Count > 1)
            {
                for (int i = 0; i < num - 1; i++)
                {
                    string reminder = queue.Dequeue();
                    queue.Enqueue(reminder);
                }
                if (PrimeTool.IsPrime(cycle))
                {
                    Console.WriteLine($"Prime {queue.Peek()}");
                }
                else
                {
                    Console.WriteLine($"Removed {queue.Dequeue()}");
                }
                cycle++;
            }
            Console.WriteLine($"Last is {queue.Dequeue()}");
        }
Exemplo n.º 3
0
        public static void Main()
        {
            var            children = Console.ReadLine().Split();
            var            number   = int.Parse(Console.ReadLine());
            Queue <string> queue    = new Queue <string>(children);

            var cycle = 1;

            while (queue.Count != 1)
            {
                for (int i = 1; i < number; i++)
                {
                    queue.Enqueue(queue.Dequeue());
                }

                if (PrimeTool.isPrime(cycle))
                {
                    Console.WriteLine($"Prime {queue.Peek()}");
                }
                else
                {
                    Console.WriteLine($"Removed {queue.Dequeue()}");
                }
                cycle++;
            }
            Console.WriteLine($"Last is {queue.Dequeue()}");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            string[] input  = Console.ReadLine().Split(' ');
            int      number = int.Parse(Console.ReadLine());

            Queue <string> names = new Queue <string>(input);
            int            cycle = 1;

            while (names.Count > 1)
            {
                for (int i = 0; i < number - 1; i++)
                {
                    names.Enqueue(names.Dequeue());
                }

                if (PrimeTool.IsPrime(cycle))
                {
                    Console.WriteLine($"Prime {names.Peek()}");
                }
                else
                {
                    Console.WriteLine($"Removed {names.Dequeue()}");
                }

                cycle++;
            }

            Console.WriteLine($"Last is {names.Dequeue()}");
        }
Exemplo n.º 5
0
        public static void Main()
        {
            var names = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var n     = int.Parse(Console.ReadLine());
            var queue = new Queue <string>(names);
            int cycle = 1;

            while (queue.Count != 1)
            {
                for (int i = 1; i < n; i++)
                {
                    queue.Enqueue(queue.Dequeue());
                }

                if (PrimeTool.IsPrime(cycle))
                {
                    Console.WriteLine($"Prime {queue.Peek()}");
                }
                else
                {
                    Console.WriteLine($"Removed {queue.Dequeue()}");
                }
                cycle++;
            }
            Console.WriteLine($"Last is {queue.Dequeue()}");
        }
Exemplo n.º 6
0
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            var n     = int.Parse(Console.ReadLine());
            var cycel = 1;

            Queue <string> queue = new Queue <string>(input);

            while (queue.Count != 1)
            {
                for (int i = 1; i < n; i++)
                {
                    queue.Enqueue(queue.Dequeue());
                }
                if (PrimeTool.IsPrime(cycel))
                {
                    Console.WriteLine($"Prime {queue.Peek()}");
                }
                else
                {
                    Console.WriteLine($"Removed {queue.Dequeue()}");
                }
                cycel++;
            }
            Console.WriteLine($"Last is {queue.Dequeue()}");
        }