Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CIRCLE
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
- int N = arr[0];
- int K = arr[1];
- int result = 0;
- int currentposition = 0;
- int del = 0;
- List<int> list = new List<int>();
- List<int> list2 = new List<int>();
- for (int i=0; i<N; i++)
- {
- int a = int.Parse(Console.ReadLine());
- list.Add(a);
- }
- for(int i=0; i<list.Count;i++)
- {
- list2.Add(i);
- }
- int b = list.Count;
- while(list.Count>1)
- {
- if (list.Count == b)
- {
- result = K + currentposition;
- }
- else
- {
- result = del + currentposition;
- }
- while(result>list.Count)
- {
- result -= list.Count;
- }
- del = list[result - 1];
- currentposition = result - 1;
- list2.Remove(list2[currentposition]);
- list.RemoveAt(currentposition);
- }
- //Console.WriteLine(String.Join("",list));
- Console.WriteLine(list2[0]+1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment