196712025-12-18 12:01:20markfsibianSorozat generáláscpp17Wrong answer 0/5034ms1344 KiB
#include <iostream>
#include <deque>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

vector<int> v;
map<int, int> la;

int m, st, a, b, l, k, mini = INT_MAX;
pair<int, bool> last = { 0, false };

int newn(int start)
{
    deque<char> s;
    int res = 0;
    start = start * a + b;

    while (start > 0)
    {
        s.push_front(start % 10);
        start = start / 10;
    }
    for (int i = s.size(); i <= m * 4 - 1; ++i)
        s.push_front(0);
    for (int i = m; i <= 3 * m - 1; ++i)
        res = res * 10 + s[i];
    return res;
}

int addns(int st1)
{
    if (l > 0)
    {
        int a;
        a = newn(st1);
        // if (!la.insert(make_pair(a, 1)).second)
        //    la[a]++;
        // if (find(v.begin(), v.end(), a) == v.end())
        v.push_back(a);
        if (find(v.begin(), v.end(), a) != v.end() && !last.second)
        {
            last.first = a;
            last.second = true;
        }
        return a;
    }
}

int main()
{
    cin >> m >> st >> a >> b >> l >> k;
    for (int i = 1; i <= l; ++i)
        st = addns(st);

    for (auto& e : v)
        cout << e << " ";
    cout << endl;
    auto elem = find(v.begin(), v.end(), last.first);
    mini = distance(elem, v.end());

    cout << mini;
    cout << endl;
    sort(v.rbegin(), v.rend());
    cout << v[k - 1];
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/028ms1188 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/22ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/22ms508 KiB
7Wrong answer0/23ms420 KiB
8Wrong answer0/44ms332 KiB
9Wrong answer0/410ms568 KiB
10Wrong answer0/428ms744 KiB
11Wrong answer0/423ms820 KiB
12Wrong answer0/434ms1008 KiB
13Wrong answer0/426ms1260 KiB
14Wrong answer0/427ms1224 KiB
15Wrong answer0/428ms1344 KiB
16Wrong answer0/428ms1252 KiB
17Wrong answer0/428ms1272 KiB