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.Text;
- using System.Threading.Tasks;
- namespace MollyDolly
- {
- class Program
- {
- static void Main(string[] args)
- {
- var path = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
- BigInteger mollysFlowers = 0;
- BigInteger dollysFlowers = 0;
- long i = 0L;
- long j = path.Length - 1;
- while (true)
- {
- long iCurrCell = i;
- long jCurrCell = j;
- if (i != j)
- {
- mollysFlowers += path[i];
- dollysFlowers += path[j];
- i += path[i];
- if (i > path.Length)
- {
- i = i - path.Length;
- }
- j -= path[j];
- if (j < 0)
- {
- j = path.Length+j;
- }
- }
- else if (i == j && path[i] % 2 == 0)
- {
- mollysFlowers += path[i] / 2;
- dollysFlowers += path[i] / 2;
- path[i] = 0;
- i += path[i];
- j += path[i];
- }
- else if (i == j)
- {
- mollysFlowers += path[i] / 2;
- dollysFlowers += path[i] / 2;
- path[i] = 1;
- i += path[i];
- j += path[i];
- }
- if (path[i]==0||path[j]==0)
- {
- if (path[i]==path[j])
- {
- Console.WriteLine("Draw");
- }
- else
- {
- Console.WriteLine(path[j] == 0 ? "Molly" : "Dolly");
- }
- Console.WriteLine(path[j] == 0 ? (mollysFlowers+path[i]) + " " + dollysFlowers :
- mollysFlowers + " " + (dollysFlowers + path[j]));
- break;
- }
- //berem cvetq
- path[iCurrCell] = 0;
- path[jCurrCell] = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement