205912026-01-07 18:38:33mikloshunorSorozat generáláscpp17Részben helyes 49/5043ms1072 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);
    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
base49/50
1Elfogadva0/01ms508 KiB
2Elfogadva0/037ms820 KiB
3Részben helyes1/21ms508 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva4/42ms540 KiB
9Elfogadva4/44ms552 KiB
10Elfogadva4/47ms480 KiB
11Elfogadva4/47ms748 KiB
12Elfogadva4/414ms708 KiB
13Elfogadva4/414ms856 KiB
14Elfogadva4/432ms1064 KiB
15Elfogadva4/413ms864 KiB
16Elfogadva4/441ms1072 KiB
17Elfogadva4/443ms820 KiB