34712023-02-28 11:37:50AGergoSorozat generáláscsharpTime limit exceeded 10/50372ms27596 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();

            double M = int.Parse(st[0]);
            long num = int.Parse(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<long> szamok = new List<long>();
            int index = -1;

            for (int i = 0; i < lepes; i++)
            {
                num = num * szorzo + add;
                
                num = num % (int)(Math.Pow(10,3*M))/10;

                if (szamok.Contains(num))
                {
                    len = i - szamok.IndexOf(num);
                    index = i;
                    break;
                }
                szamok.Add(num);
            }
            for (int i = index; i < lepes; i++)
            {
                szamok.Add(szamok[i - len]);
            }
            szamok.Sort();
            szamok.Reverse();

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

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base10/50
1Accepted0/032ms20996 KiB
2Time limit exceeded0/0344ms4620 KiB
3Accepted2/232ms22008 KiB
4Accepted2/232ms21860 KiB
5Accepted2/234ms22488 KiB
6Accepted2/232ms22696 KiB
7Accepted2/235ms23344 KiB
8Wrong answer0/439ms23864 KiB
9Wrong answer0/443ms23988 KiB
10Wrong answer0/446ms25164 KiB
11Wrong answer0/448ms25272 KiB
12Wrong answer0/454ms26192 KiB
13Time limit exceeded0/4356ms6880 KiB
14Time limit exceeded0/4345ms7244 KiB
15Wrong answer0/4116ms27212 KiB
16Wrong answer0/4180ms27596 KiB
17Time limit exceeded0/4372ms7440 KiB