221882026-01-14 17:40:20hunzombiSorozat generáláscpp17Hibás válasz 28/5017ms1744 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll m, x, a, b, n, k;

    cin >> m >> x >> a >> b >> n >> k;

    ll p = 1;
    for (int i=0; i < m; i++) p *= 10;
    ll p2 = p * p;

    vi seq;
    seq.reserve(n);

    unordered_map<int, int> last_pos;
    last_pos.reserve(n);

    int ans_dist = INT_MAX;

    ll curr = x;

    for (int i=0; i < n; i++) {
        ll y = curr * a + b;

        int next = (y / p) % p2;

        seq.push_back(next);

        if (last_pos.count(next)) {
            ans_dist = min(ans_dist, i - last_pos[next]);
        }
        last_pos[next] = i;

        curr = next;
    }

    sort(seq.begin(), seq.end());

    cout << ans_dist << '\n' << seq[k] << '\n';

    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base28/50
1Elfogadva0/01ms512 KiB
2Hibás válasz0/016ms1588 KiB
3Részben helyes1/21ms316 KiB
4Részben helyes1/21ms316 KiB
5Részben helyes1/22ms316 KiB
6Részben helyes1/21ms316 KiB
7Elfogadva2/22ms316 KiB
8Részben helyes2/42ms316 KiB
9Részben helyes2/44ms564 KiB
10Részben helyes2/48ms1052 KiB
11Részben helyes2/47ms880 KiB
12Részben helyes2/410ms1076 KiB
13Elfogadva4/413ms1572 KiB
14Részben helyes2/414ms1568 KiB
15Részben helyes2/414ms1728 KiB
16Részben helyes2/416ms1736 KiB
17Részben helyes2/417ms1744 KiB