34522023-02-28 09:26:00AGergoSorozat generáláscsharpRuntime error 18/50400ms25336 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

            List<string> szamok = 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.Contains(num))
                {
                    len = i - szamok.LastIndexOf(num);
                    
                    index = i;
                    break;
                }
                szamok.Add(num);
            }

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



            Console.WriteLine(len);

            szamok.Sort();
            szamok.Reverse();


            Console.WriteLine(szamok[k-1]);

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/035ms22004 KiB
2Runtime error0/032ms20988 KiB
3Accepted2/232ms22696 KiB
4Accepted2/254ms23392 KiB
5Accepted2/246ms23600 KiB
6Accepted2/250ms24048 KiB
7Accepted2/235ms24476 KiB
8Accepted4/494ms24416 KiB
9Accepted4/4237ms25336 KiB
10Time limit exceeded0/4372ms8108 KiB
11Time limit exceeded0/4358ms8192 KiB
12Time limit exceeded0/4358ms9008 KiB
13Runtime error0/437ms24008 KiB
14Time limit exceeded0/4400ms10528 KiB
15Runtime error0/437ms24756 KiB
16Runtime error0/432ms24372 KiB
17Runtime error0/435ms24296 KiB