79012024-01-11 19:09:28czitaSorozat generáláscsharpAccepted 50/5083ms27832 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace sorozatgeneralas
{
    class Program
    {
        static int general(int m, int a, int b, int x)
        {
            int szam = 0;
            ulong y = (ulong)x * (ulong)a + (ulong)b;
            string s = y.ToString();
            if (s.Length < m * 4)
            {
                s = new string('0', m * 4 - s.Length) + s;
            }
            int h = s.Length;
            szam = int.Parse(s.Substring(m, m * 2));
            //ulong y = (ulong)x * (ulong)a + (ulong)b;
            //y %= (ulong)Math.Pow(10, m * 3);
            //y /= (ulong)Math.Pow(10, m );
            return szam;
        }
        static void Main(string[] args)
        {
            int[] st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int M = st[0];
            int X = st[1];
            int A = st[2];
            int B = st[3];
            int N = st[4];
            int K = st[5];
            List<int> lista = new List<int>();
            //lista.Add(X);
            for (int i = 0; i < N; i++)
            {
                X = general(M, A, B, X);
                if (!lista.Contains(X))
                {
                    lista.Add(X);
                }
                else
                {
                    break;
                }
               // Console.WriteLine(X+" ");
            }
          //  Console.WriteLine(X);
            List<int> listacopy = new List<int>(lista);
            while (listacopy[0] != X)
            {
                listacopy.RemoveAt(0);
            }
            Console.WriteLine(listacopy.Count);
            int li = 0;
            for (int i = lista.Count; i < N; i++)
            {
                if (li==listacopy.Count)
                {
                    li = 0;
                }
                lista.Add(listacopy[li]);
                li++;
            }
            lista.Sort();
            lista.Reverse();
            Console.WriteLine(lista[K-1]);
            //foreach (var item in lista)
            //{
            //    Console.Write(item + " ");
            //}
            Console.ReadKey();


        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/037ms22480 KiB
2Accepted0/072ms24356 KiB
3Accepted2/235ms23080 KiB
4Accepted2/237ms23164 KiB
5Accepted2/237ms23676 KiB
6Accepted2/235ms24104 KiB
7Accepted2/237ms24440 KiB
8Accepted4/439ms24688 KiB
9Accepted4/443ms25128 KiB
10Accepted4/452ms25364 KiB
11Accepted4/450ms25428 KiB
12Accepted4/457ms26408 KiB
13Accepted4/474ms26636 KiB
14Accepted4/474ms26684 KiB
15Accepted4/471ms27000 KiB
16Accepted4/481ms27288 KiB
17Accepted4/483ms27832 KiB