205932026-01-07 18:39:58mikloshunorSorozat generáláscpp17Elfogadva 50/5043ms996 KiB
#include <iostream>
#include <vector>
#include <map>
#include <bits/stdc++.h> //igy nem kell a tobbi
using namespace std;

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

    sort(v.begin(), v.end() -1);
    cout << mintav << endl;
    cout << v[n - k];
    return 0;
}

RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/037ms820 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms420 KiB
6Elfogadva2/21ms412 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva4/42ms316 KiB
9Elfogadva4/44ms496 KiB
10Elfogadva4/47ms564 KiB
11Elfogadva4/46ms564 KiB
12Elfogadva4/414ms704 KiB
13Elfogadva4/413ms860 KiB
14Elfogadva4/432ms856 KiB
15Elfogadva4/413ms864 KiB
16Elfogadva4/441ms996 KiB
17Elfogadva4/443ms924 KiB