34332023-02-27 18:04:18norbertvidaSorozat generáláscpp17Partially correct 49/5016ms6380 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;
    adatok.push_back(X);
    utolso[X] = 0;
    lli tiz_m = ((const int[]){ 10, 100, 1000 })[M - 1];
    lli tiz_2m = tiz_m * tiz_m;
    int i;
    for(i = 1; i < N; i++) {
        X = (((X * A) + B) / tiz_m) % tiz_2m;
        adatok.push_back(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.push_back(X);
    }
    sort(adatok.rbegin(), adatok.rend());
    cout << adatok[K - 1] << "\n";
}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/03ms1704 KiB
2Accepted0/014ms4084 KiB
3Partially correct1/23ms2232 KiB
4Accepted2/23ms2552 KiB
5Accepted2/23ms2764 KiB
6Accepted2/23ms2932 KiB
7Accepted2/23ms3068 KiB
8Accepted4/43ms3092 KiB
9Accepted4/44ms3756 KiB
10Accepted4/48ms4328 KiB
11Accepted4/48ms4572 KiB
12Accepted4/410ms5696 KiB
13Accepted4/413ms5904 KiB
14Accepted4/414ms5904 KiB
15Accepted4/413ms6148 KiB
16Accepted4/416ms6232 KiB
17Accepted4/416ms6380 KiB