Advertisement
Sim0o0na

Untitled

Feb 25th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ProblemII
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<int> snowmen = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  14. .Select(int.Parse).ToList();
  15. while (snowmen.Count > 1)
  16. {
  17. for (int i = 0; i < snowmen.Count; i++)
  18. {
  19. for (int j = 0; j < snowmen.Count; j++)
  20. {
  21. int target = snowmen[i];
  22. if (target >= snowmen.Count)
  23. {
  24. target %= snowmen.Count;
  25. }
  26.  
  27. if (target == j)
  28. {
  29. int fight = Math.Abs(i - j);
  30. if (fight == 0)
  31. {
  32. Console.WriteLine($"{i} performed harakiri");
  33. snowmen[i] = -1;
  34. }
  35. else if (fight % 2 == 0)
  36. {
  37. Console.WriteLine($"{i} x {j} -> {i} wins");
  38. snowmen[j] = -1;
  39. }
  40. else if (fight % 2 != 0)
  41. {
  42. Console.WriteLine($"{i} x {j} -> {j} wins");
  43. snowmen[i] = -1;
  44. }
  45.  
  46. List<int> temp = new List<int>(snowmen.Where(x => x != -1));
  47. if (temp.Count == 1)
  48. return;
  49. }
  50. }
  51. }
  52.  
  53. snowmen.RemoveAll(x => x == -1);
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement