34932023-02-28 12:47:17gergoSorozat generáláscsharpRuntime error 30/5097ms28780 KiB
using System;
using System.Collections.Generic;
using System.Linq;

namespace sorozatgeneralas
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] elsosor = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int m = elsosor[0], x = elsosor[1], a =elsosor[2], b=elsosor[3], n=elsosor[4], k=elsosor[5];

            List<int> lista = new List<int>();

            long szam;
            int num=0;

            for (int i = 0; i < n; i++)
            {   
                szam = x * a + b;
                string szam2 = Convert.ToString(szam);

                szam2 = new string('0', m * 4 - szam2.Length)+szam2;

                szam2 = szam2.Substring(m, m * 2);
                //while (szam2.Length < 4 * m) szam2 = "0" + szam2;

                //if (lista.Contains(int.Parse(szam2.Substring(szam2.Length / 2 - 1, 2 * m)))) 
                //{
                //    num = int.Parse(szam2.Substring(szam2.Length / 2 - 1, 2 * m));
                //    break; 
                //}
                x = int.Parse(szam2);

                if (lista.Contains(x))
                {
                    num = x;
                    break;
                }
                else
                {
                    lista.Add(x);
                }
               

            }

            int n2 =lista.Count - lista.IndexOf((int)num);
            

            for (int i = lista.Count; i < n; i++)
            {
                lista.Add(lista[i-n2]);
            }

            lista.Sort();

            Console.WriteLine(n2);
            Console.WriteLine(lista[lista.Count-k]);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/035ms22292 KiB
2Runtime error0/034ms21944 KiB
3Accepted2/235ms23020 KiB
4Accepted2/235ms23608 KiB
5Accepted2/235ms24076 KiB
6Accepted2/235ms24148 KiB
7Accepted2/235ms24772 KiB
8Accepted4/437ms25016 KiB
9Accepted4/441ms25688 KiB
10Accepted4/450ms25848 KiB
11Accepted4/450ms26232 KiB
12Accepted4/457ms27284 KiB
13Runtime error0/435ms24940 KiB
14Wrong answer0/497ms28780 KiB
15Runtime error0/437ms25148 KiB
16Runtime error0/435ms25540 KiB
17Runtime error0/435ms25540 KiB