Advertisement
Guest User

holly dolly

a guest
May 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace MollyDolly
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. var path = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  15. BigInteger mollysFlowers = 0;
  16. BigInteger dollysFlowers = 0;
  17.  
  18. long i = 0L;
  19. long j = path.Length - 1;
  20. while (true)
  21. {
  22. long iCurrCell = i;
  23. long jCurrCell = j;
  24.  
  25. if (i != j)
  26. {
  27. mollysFlowers += path[i];
  28. dollysFlowers += path[j];
  29.  
  30. i += path[i];
  31. if (i > path.Length)
  32. {
  33. i = i - path.Length;
  34. }
  35.  
  36. j -= path[j];
  37. if (j < 0)
  38. {
  39. j = path.Length+j;
  40. }
  41. }
  42.  
  43. else if (i == j && path[i] % 2 == 0)
  44. {
  45. mollysFlowers += path[i] / 2;
  46. dollysFlowers += path[i] / 2;
  47. path[i] = 0;
  48. i += path[i];
  49. j += path[i];
  50. }
  51. else if (i == j)
  52. {
  53. mollysFlowers += path[i] / 2;
  54. dollysFlowers += path[i] / 2;
  55. path[i] = 1;
  56. i += path[i];
  57. j += path[i];
  58. }
  59.  
  60. if (path[i]==0||path[j]==0)
  61. {
  62. if (path[i]==path[j])
  63. {
  64. Console.WriteLine("Draw");
  65. }
  66. else
  67. {
  68.  
  69. Console.WriteLine(path[j] == 0 ? "Molly" : "Dolly");
  70. }
  71. Console.WriteLine(path[j] == 0 ? (mollysFlowers+path[i]) + " " + dollysFlowers :
  72. mollysFlowers + " " + (dollysFlowers + path[j]));
  73. break;
  74. }
  75. //berem cvetq
  76. path[iCurrCell] = 0;
  77. path[jCurrCell] = 0;
  78.  
  79. }
  80.  
  81.  
  82. }
  83.  
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement