34622023-02-28 10:59:35vááááSorozat generáláscsharpWrong answer 42/5076ms26824 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]);
            Dictionary<Int64, int> utoljara = new Dictionary<long, int>();
            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));
            bool megvan = false;
            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));
                if (!megvan)
                {
                    if (utoljara.ContainsKey(sor[i])) {
                        Console.WriteLine(i - utoljara[sor[i]]);
                        megvan = true;
                    }
                    else utoljara.Add(sor[i], i);
                }
            }
            Array.Sort(sor);
            Console.WriteLine(sor[n  - k]); ;
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base42/50
1Accepted0/035ms21272 KiB
2Accepted0/074ms23208 KiB
3Accepted2/232ms21748 KiB
4Accepted2/234ms21876 KiB
5Accepted2/235ms22116 KiB
6Accepted2/234ms22416 KiB
7Accepted2/235ms22516 KiB
8Accepted4/435ms23140 KiB
9Accepted4/441ms23384 KiB
10Accepted4/452ms24184 KiB
11Accepted4/452ms24144 KiB
12Accepted4/461ms24380 KiB
13Wrong answer0/468ms25564 KiB
14Accepted4/468ms25772 KiB
15Accepted4/471ms25876 KiB
16Accepted4/476ms26424 KiB
17Wrong answer0/475ms26824 KiB