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;
- class DrunkAni
- {
- static void Main()
- {
- long n = long.Parse(Console.ReadLine());
- decimal[] numberOfCabins = new decimal[n];
- long currentPosition = 0;
- long totalLengthCovered = 0;
- for (int i = 0; i < n; i++)
- {
- numberOfCabins[i] = i;
- }
- string nextComand = Console.ReadLine();
- while (nextComand!="Found a free one!")
- {
- long oldPosition = currentPosition;
- currentPosition = (currentPosition+long.Parse(nextComand))%n;
- long difference = currentPosition - oldPosition;
- if (difference>0)
- {
- Console.WriteLine("Go {0} steps to the right, Ani.",difference);
- }
- else if (difference<0)
- {
- Console.WriteLine("Go {0} steps to the left, Ani.",Math.Abs(currentPosition - oldPosition));
- }
- else
- {
- Console.WriteLine("Stay there, Ani.");
- }
- totalLengthCovered += Math.Abs(currentPosition - oldPosition);
- nextComand = Console.ReadLine();
- }
- Console.WriteLine("Moved a total of {0} steps.",totalLengthCovered);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment