34342023-02-27 18:31:20norbertvidaSorozat generáláscpp17Accepted 50/5016ms5524 KiB
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    lli M, X, A, B, N, K;
    cin >> M >> X >> A >> B >> N >> K;
    map<lli, lli> utolso;
    vector<lli> adatok(N);
    utolso[X] = 0;
    lli tiz_m = ((const lli[]){ 10LL, 100LL, 1000LL })[M - 1];
    lli tiz_2m = tiz_m * tiz_m;
    lli i;
    for(i = 0; i < N; i++) {
        X = (((X * A) + B) / tiz_m) % tiz_2m;
        adatok[i] = X;
        if(utolso.count(X)) {
            cout << i - utolso[X] << "\n";
            break;
        }
        utolso[X] = i;
    }
    for(; i < N; i++) {
        X = (((X * A) + B) / tiz_m) % tiz_2m;
        adatok[i] = X;
    }
    sort(adatok.rbegin(), adatok.rend());
    cout << adatok[K - 1] << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/014ms3516 KiB
3Accepted2/22ms2128 KiB
4Accepted2/23ms2520 KiB
5Accepted2/23ms2472 KiB
6Accepted2/23ms2452 KiB
7Accepted2/23ms2812 KiB
8Accepted4/43ms2848 KiB
9Accepted4/44ms2872 KiB
10Accepted4/48ms3648 KiB
11Accepted4/47ms3856 KiB
12Accepted4/49ms4308 KiB
13Accepted4/412ms5056 KiB
14Accepted4/413ms4748 KiB
15Accepted4/412ms5268 KiB
16Accepted4/414ms5292 KiB
17Accepted4/416ms5524 KiB