34592023-02-28 10:45:00vááááSorozat generáláscsharpTime limit exceeded 30/50400ms24848 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 c = Console.ReadLine();
            int m = int.Parse(c.Split()[0]);
            int x = int.Parse(c.Split()[1]);
            int a = int.Parse(c.Split()[2]);
            int b = int.Parse(c.Split()[3]);
            int n = int.Parse(c.Split()[4]);
            int k = int.Parse(c.Split()[5]);
            long[] sor = new long[n];
            if (m == 1)
                m = 10;
            if (m == 2)
                m = 100;
            if (m == 3)
                m = 1000;
            sor[0] = Convert.ToInt64(Math.Floor((double)(x * a + b)/m));
            if(sor[0] / (m*m) >= 1)
                sor[0] = Convert.ToInt64(sor[0] - Math.Floor((double)sor[0] / (m*m)) * (m*m));
            for (int i = 1; i < n; i++)
            {
                sor[i] = Convert.ToInt64(Math.Floor((double)(sor[i - 1] * a + b) / m));
                if (sor[i] / (m*m) >= 1)
                    sor[i] = Convert.ToInt64(sor[i] - Math.Floor((double)sor[i] / (m*m)) * (m* m));

            }
            int tav = int.MaxValue;
            for (int i = 0; i < n; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    if(sor[i] == sor[j])
                    {
                        tav = j - i;
                        break;
                    }
                    if(j-i > tav )
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(tav);
            Array.Sort(sor);
            Console.WriteLine(sor[n  - k]); ;
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/030ms20712 KiB
2Time limit exceeded0/0400ms4904 KiB
3Accepted2/229ms21448 KiB
4Accepted2/234ms22096 KiB
5Accepted2/232ms22260 KiB
6Accepted2/232ms22696 KiB
7Accepted2/232ms22704 KiB
8Accepted4/441ms23104 KiB
9Accepted4/468ms23388 KiB
10Accepted4/4138ms23872 KiB
11Accepted4/498ms24040 KiB
12Accepted4/4152ms24848 KiB
13Time limit exceeded0/4352ms8136 KiB
14Time limit exceeded0/4374ms8544 KiB
15Time limit exceeded0/4367ms8892 KiB
16Time limit exceeded0/4370ms8788 KiB
17Time limit exceeded0/4367ms8772 KiB