34612023-02-28 10:54:53AGergoSorozat generáláscsharpRuntime error 18/50367ms25004 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sorozat
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split();

            int M = int.Parse(st[0]);
            string num = st[1];
            int szorzo = int.Parse(st[2]);
            int add = int.Parse(st[3]);
            int lepes = int.Parse(st[4]);
            int k = int.Parse(st[5]); // k. legnagyobb elem kell

            int len = lepes + 1; //tavolsag a ket ugyanolyan szam közt

            Dictionary<string, int> szamok = new Dictionary<string, int>();

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

            int index = -1;

            for (int i = 0; i < lepes; i++)
            {
                num = (int.Parse(num) * szorzo + add).ToString();
                while (num.Length != 4 * M)
                {
                    num = "0" + num;
                }
                
                num = num.Substring(M, 2 * M);

                if (szamok.ContainsKey(num))
                {
                    len = i - szamok[num];
                    
                    index = i;
                    break;
                }
                szamok.Add(num, i);
                lista.Add(num);
            }

            for (int i = index; i < lepes; i++)
            {
                lista.Add(lista[i - len]);
            }
            lista.Sort();

            Console.WriteLine(len);
            
            Console.WriteLine(lista[lepes-k]);

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/035ms21872 KiB
2Runtime error0/034ms20792 KiB
3Accepted2/235ms23036 KiB
4Accepted2/257ms23424 KiB
5Accepted2/246ms23400 KiB
6Accepted2/250ms23820 KiB
7Accepted2/239ms24228 KiB
8Accepted4/497ms24668 KiB
9Accepted4/4238ms25004 KiB
10Time limit exceeded0/4365ms7844 KiB
11Time limit exceeded0/4354ms7872 KiB
12Time limit exceeded0/4367ms8708 KiB
13Runtime error0/434ms24124 KiB
14Time limit exceeded0/4363ms10600 KiB
15Runtime error0/434ms24140 KiB
16Runtime error0/435ms24392 KiB
17Runtime error0/434ms24688 KiB