34662023-02-28 11:22:16AGergoSorozat generáláscsharpTime limit exceeded 10/50384ms25860 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]);
            int 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<int> szamok = new List<int>();
            int index = -1;

            for (int i = 0; i < lepes; i++)
            {
                num = num * szorzo + add;
                
                num = (num % Convert.ToInt32(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/032ms21376 KiB
2Time limit exceeded0/0384ms4556 KiB
3Accepted2/230ms21464 KiB
4Accepted2/232ms22340 KiB
5Accepted2/232ms22476 KiB
6Accepted2/232ms22720 KiB
7Accepted2/232ms22812 KiB
8Wrong answer0/439ms23036 KiB
9Wrong answer0/441ms23600 KiB
10Wrong answer0/446ms23544 KiB
11Wrong answer0/448ms24092 KiB
12Wrong answer0/457ms25472 KiB
13Time limit exceeded0/4314ms25796 KiB
14Time limit exceeded0/4354ms7248 KiB
15Time limit exceeded0/4361ms7120 KiB
16Wrong answer0/4216ms25536 KiB
17Wrong answer0/4300ms25860 KiB