34652023-02-28 11:19:27tothgergelySorozat generáláscsharpAccepted 50/5081ms27420 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static long general(int m, int a, int b, int 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];
            int X = szam[1];
            int A = szam[2];
            int B = szam[3];
            int N = szam[4];
            int K = szam[5];
            int kezd = 0; int veg = 0;
            List<int> l = new List<int>();
            for (int i = 0; i < N; i++)
            {
               X = (int) general(M, A, B, X);
                if (l.Contains(X))
                {
                    veg = i;
                    break;
                }
                else
                {
                    l.Add(X);
                }
            }
            kezd = l.IndexOf(X);
            for (int i = l.Count; i < N; i++)
            {
                l.Add(l[i - (veg - kezd)]);
            }
            
            Console.WriteLine(veg - kezd);
            l.Sort();
            Console.WriteLine(l[l.Count - K]);

            
            
            
            
            
            
            
            Console.ReadKey();

        }
    }

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/035ms22488 KiB
2Accepted0/071ms24416 KiB
3Accepted2/235ms23340 KiB
4Accepted2/235ms23716 KiB
5Accepted2/235ms24136 KiB
6Accepted2/235ms24148 KiB
7Accepted2/235ms24136 KiB
8Accepted4/437ms24172 KiB
9Accepted4/441ms24836 KiB
10Accepted4/450ms25520 KiB
11Accepted4/448ms25748 KiB
12Accepted4/457ms27172 KiB
13Accepted4/470ms27052 KiB
14Accepted4/471ms27396 KiB
15Accepted4/468ms27420 KiB
16Accepted4/475ms27396 KiB
17Accepted4/481ms27300 KiB