Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<int> losesIndexes = new List<int>();
- int attackIndex = 0;
- int attackValue = 0;
- BigInteger difference = 0;
- while (inputNum.Count != 1)
- {
- for (int i = 0; i < inputNum.Count; i++)
- {
- if (inputNum[i] > inputNum.Count)
- {
- inputNum[i] = inputNum[i] % inputNum.Count;
- }
- if (losesIndexes.Contains(i))
- {
- continue;
- }
- attackIndex = i;
- attackValue = inputNum[i];
- difference = BigInteger.Abs(attackIndex - attackValue);
- if (difference.IsEven && !difference.IsZero)
- {
- if (i < inputNum.Count - 1)
- {
- Console.WriteLine($"{attackIndex} x {attackValue} -> {attackIndex} wins");
- losesIndexes.Add(attackValue);
- }
- }
- else if (!difference.IsEven)
- {
- if (i < inputNum.Count - 1)
- {
- Console.WriteLine($"{attackIndex} x {attackValue} -> {attackValue} wins");
- losesIndexes.Add(attackIndex);
- }
- }else if (difference.IsZero)
- {
- if (i < inputNum.Count - 1)
- {
- Console.WriteLine($"{attackIndex} performed harakiri");
- losesIndexes.Add(attackIndex);
- }
- }
- }
- while (losesIndexes.Count > 0)
- {
- for (int j = 0; j < losesIndexes.Count; j++)
- {
- inputNum[losesIndexes[j]] = -10;
- }
- // losesIndexes.RemoveAll(a=> a>int.MinValue);
- for (int i = 0; i < inputNum.Count; i++)
- {
- if (inputNum[i] == -10)
- {
- inputNum.RemoveAt(i);
- i--;
- }
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment