34672023-02-28 11:22:51AGergoSorozat generáláscsharpWrong answer 10/50365ms25792 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]);

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base10/50
1Wrong answer0/032ms21016 KiB
2Time limit exceeded0/0365ms4244 KiB
3Accepted2/232ms21784 KiB
4Accepted2/235ms22108 KiB
5Accepted2/232ms22432 KiB
6Accepted2/232ms22796 KiB
7Accepted2/232ms22940 KiB
8Wrong answer0/437ms23028 KiB
9Wrong answer0/441ms23196 KiB
10Wrong answer0/445ms23536 KiB
11Wrong answer0/448ms23544 KiB
12Wrong answer0/454ms24788 KiB
13Time limit exceeded0/4314ms24716 KiB
14Time limit exceeded0/4354ms6276 KiB
15Time limit exceeded0/4358ms6296 KiB
16Wrong answer0/4216ms25284 KiB
17Time limit exceeded0/4300ms25792 KiB