34702023-02-28 11:35:30AGergoSorozat generáláscsharpTime limit exceeded 10/50377ms25912 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 % (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/032ms21128 KiB
2Time limit exceeded0/0361ms4608 KiB
3Accepted2/232ms21908 KiB
4Accepted2/232ms22304 KiB
5Accepted2/232ms22800 KiB
6Accepted2/232ms23072 KiB
7Accepted2/232ms22684 KiB
8Wrong answer0/435ms23452 KiB
9Wrong answer0/441ms23456 KiB
10Wrong answer0/445ms24060 KiB
11Wrong answer0/446ms24376 KiB
12Wrong answer0/454ms25348 KiB
13Wrong answer0/4284ms25328 KiB
14Time limit exceeded0/4377ms7336 KiB
15Time limit exceeded0/4367ms7212 KiB
16Wrong answer0/4197ms25912 KiB
17Wrong answer0/4270ms25432 KiB