28732023-02-01 12:28:55tamasmarkSorozat generáláscpp17Accepted 50/5029ms20472 KiB

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

vector<long long>x;
long long n, k, m, i, a, b, kezd, akt, c, z, o, j;
struct hossz
{
    long long szam, hely;
};
hossz y[1000000];

bool comp(long long a, long long b)
{
    return a > b;
}

int main()
{
    cin >> m >> kezd >> a >> b >> n >> k;
    akt = kezd;
    for (i = 1; i <= n; ++i)
    {
        akt = (akt * a) + b;
        o = pow(10, m);
        akt = akt / o;
        o = pow(10, 2 * m);
        akt = akt % o;
        x.push_back(akt);
    }
    for (i = 0; i < x.size(); ++i)
    {
        if (y[x[i]].szam == 0)
        {
            y[x[i]].szam++;
            y[x[i]].hely = i;
        }
        else if (y[x[i]].szam != 0)
        {
            cout << i - y[x[i]].hely << "\n";
            break;
        }
    }
    sort(x.begin(), x.end(),comp);
    cout<<x[k-1];
    
    return 0;
}
/*
1 73 11 50 20 10
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1756 KiB
2Accepted0/026ms12020 KiB
3Accepted2/23ms2168 KiB
4Accepted2/23ms2620 KiB
5Accepted2/23ms2868 KiB
6Accepted2/23ms3024 KiB
7Accepted2/23ms3140 KiB
8Accepted4/44ms3424 KiB
9Accepted4/46ms3888 KiB
10Accepted4/410ms4540 KiB
11Accepted4/410ms4500 KiB
12Accepted4/416ms5328 KiB
13Accepted4/425ms17496 KiB
14Accepted4/427ms17640 KiB
15Accepted4/425ms15416 KiB
16Accepted4/428ms18428 KiB
17Accepted4/429ms20472 KiB