Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Globalization;
- namespace Feb26_2018
- {
- class MainClass
- {
- /* */
- public static void Main()
- {
- //int k = int.Parse(Console.ReadLine());
- //var input = Console.ReadLine()
- // .Split()
- // .Select(double.Parse)
- // .ToList();
- //var firstK = input.Take(k);
- //var asd = input.ToArray().Reverse();
- //Console.WriteLine(asd);
- var input = Console.ReadLine();
- string[] inputToArray = input.Split();
- List<int> snowmen = new List<int>();
- int attacker = 0;
- int target = 0;
- // int remainderTargetToLength = 0;
- for (int assignmentIndex = 0; assignmentIndex < inputToArray.Length; assignmentIndex++)
- {
- snowmen[assignmentIndex] = int.Parse(inputToArray[assignmentIndex]);
- }
- for (int gameRound = 0; gameRound < snowmen.Count(); gameRound++)
- {
- while(snowmen.Count() > 1)
- {
- attacker = gameRound;
- target = snowmen[gameRound];
- int winner = 0;
- bool attackerWins = Math.Abs(attacker - target) % 2 == 0;
- bool targetWins = Math.Abs(attacker - target) % 2 != 0;
- bool attackerSuicides = attacker == target;
- if (target > snowmen.Count())
- {
- target = target % snowmen.Count();
- }
- if (attackerWins)
- {
- winner = attacker;
- snowmen.RemoveAt(gameRound);
- }
- else if (targetWins)
- {
- winner = target;
- snowmen.RemoveAt(gameRound);
- }
- else if (attackerSuicides)
- {
- snowmen.RemoveAt(attacker);
- }
- if (winner == attacker || winner == target)
- {
- Console.WriteLine($"{attacker} x {target} -> {winner} wins");
- }
- else if (attackerSuicides)
- {
- Console.WriteLine($"{attacker} performed harakiri.");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement