28722023-02-01 12:25:12tamasmarkSorozat generáláscpp17Wrong answer 50/5030ms20660 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];
    
    return 0;
}
/*
1 73 11 50 20 10
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Wrong answer0/03ms1880 KiB
2Accepted0/026ms12284 KiB
3Accepted2/23ms2384 KiB
4Accepted2/23ms2740 KiB
5Accepted2/23ms2956 KiB
6Accepted2/23ms3116 KiB
7Accepted2/24ms3272 KiB
8Accepted4/44ms3816 KiB
9Accepted4/46ms4240 KiB
10Accepted4/410ms4756 KiB
11Accepted4/410ms4772 KiB
12Accepted4/416ms6008 KiB
13Accepted4/426ms18432 KiB
14Accepted4/426ms18372 KiB
15Accepted4/425ms16060 KiB
16Accepted4/428ms19060 KiB
17Accepted4/430ms20660 KiB