34692023-02-28 11:28:57BenedekSorozat generáláscsharpAccepted 50/5081ms27796 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sorozat_generálás
{
    class Program
    {
        static long general(int m, int a, int b, long x)
        {
            

                long szam = (long)x * (long)a + (long)b;
                szam %= (long)Math.Pow(10, 3 * m);
                szam /= (long)Math.Pow(10, m);
                return szam;
            }
        static void Main(string[] args)
        {
            int[] szam = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int M = szam[0];
            long X = szam[1];
            int A = szam[2];
            int B = szam[3];
            int N = szam[4];
            int K = szam[5];

            long[] szamok = new long[N];
            int ismhossz = 0;

            for (int i = 0; i < N; i++)
            {
                szamok[i] = general(M, A, B, X);
                X = szamok[i];

            }


            Dictionary<long, int> hely = new Dictionary<long, int>();

            for (int i = 0; i < N; i++)
            {
                if (hely.ContainsKey(szamok[i]))
                {
                    ismhossz = i - hely[szamok[i]];
                    break;
                }
                hely.Add(szamok[i], i);

            }

            Console.WriteLine(ismhossz);
            Array.Sort(szamok);
            Console.WriteLine(szamok[N-K]);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/037ms22700 KiB
2Accepted0/079ms24144 KiB
3Accepted2/237ms23628 KiB
4Accepted2/239ms23928 KiB
5Accepted2/237ms23964 KiB
6Accepted2/237ms24056 KiB
7Accepted2/239ms24052 KiB
8Accepted4/439ms24688 KiB
9Accepted4/445ms24968 KiB
10Accepted4/457ms25348 KiB
11Accepted4/456ms25500 KiB
12Accepted4/464ms26304 KiB
13Accepted4/472ms26472 KiB
14Accepted4/475ms26632 KiB
15Accepted4/475ms26528 KiB
16Accepted4/481ms27428 KiB
17Accepted4/481ms27796 KiB