205732026-01-07 18:23:33mikloshunorSorozat generáláscpp17Wrong answer 30/5045ms1292 KiB
#include <iostream>
#include <vector>
#include <map>
#include <bits/stdc++.h> //igy nem kell a tobbi
using namespace std;

int main()
{
    int m, x, a, b, n, k;
    cin >> m >> x >> a >> b >> n >> k;
    vector <int> v(n);
    map <int, int> tav;
    int hat = pow(10,m);
    int mintav = INT_MAX;
    for (int i = 1; i <= n; i++)
    {
        x = x * a + b;
        x = (x / hat) % (hat * hat);
        v.push_back(x);
        if (tav.count(x))
        {
            if (mintav > i - tav[x])
            {
                mintav = i - tav [x];
            }
        }
        tav[x] = i;
    }

    sort(v.begin(), v.end());
    auto it = v.end() - k;
    cout << mintav << endl;
    cout << *it;
    return 0;
}

SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/01ms512 KiB
2Wrong answer0/045ms1292 KiB
3Accepted2/21ms316 KiB
4Accepted2/22ms316 KiB
5Accepted2/21ms332 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted4/42ms392 KiB
9Accepted4/44ms756 KiB
10Accepted4/48ms672 KiB
11Accepted4/47ms820 KiB
12Accepted4/414ms820 KiB
13Wrong answer0/425ms1076 KiB
14Wrong answer0/435ms1188 KiB
15Wrong answer0/417ms1184 KiB
16Wrong answer0/430ms1152 KiB
17Wrong answer0/441ms1276 KiB