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.IO;
- namespace laser
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (File.Exists("input.txt"))
- {
- Console.SetIn(new StreamReader("input.txt"));
- }
- int n = int.Parse(Console.ReadLine());
- var list = new LinkedList<int>();
- for (int i =1 ; i <= n; i += 1)
- {
- list.AddLast(i);
- }
- int lastLamp = 0;
- int currentTurn = 1;
- while (list.Count > 0)
- {
- int step = currentTurn + 1;
- var node = list.First;
- var cnt = list.Count;
- for (int i = 0; i < cnt; i++)
- {
- var nextNode = node.Next;
- if (i % step == 0)
- {
- lastLamp = node.Value;
- list.Remove(node);
- }
- node = nextNode;
- if (node == null)
- break;
- }
- currentTurn += 1;
- }
- Console.WriteLine(lastLamp);
- for (int i = 0; i < 2; i++)
- {
- int dx = 1;
- int dy = 0;
- int x = 0;
- int y = 0;
- var commands = Console.ReadLine();
- for (int j = 0; j < 4; j++)
- foreach (char command in commands)
- {
- if (command == 'S')
- {
- x += dx;
- y += dy;
- }
- else if (command == 'L' || command == 'R')
- {
- // turn left
- if (x == 1)
- {
- x = 0;
- y = 1;
- }
- else if (x == -1)
- {
- x = 0;
- y = -1;
- }
- else if (y == 1)
- {
- x = -1;
- y = 0;
- }
- else if (y == -1)
- {
- x = 1;
- y = 0;
- }
- if (command == 'R')
- {
- x *= -1;
- y *= -1;
- }
- }
- }
- if (x == 0 && y == 0)
- Console.WriteLine("bounded");
- else
- Console.WriteLine("unbounded");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment