34312023-02-27 15:02:37norbertvidaSorozat generáláscpp17Wrong answer 49/5016ms6512 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;
        } else {
            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
1Wrong answer0/03ms1824 KiB
2Accepted0/016ms4272 KiB
3Partially correct1/23ms2320 KiB
4Accepted2/23ms2592 KiB
5Accepted2/23ms2944 KiB
6Accepted2/23ms3020 KiB
7Accepted2/23ms3100 KiB
8Accepted4/44ms3380 KiB
9Accepted4/44ms4000 KiB
10Accepted4/48ms4776 KiB
11Accepted4/48ms5016 KiB
12Accepted4/410ms6028 KiB
13Accepted4/413ms6320 KiB
14Accepted4/414ms6352 KiB
15Accepted4/413ms6160 KiB
16Accepted4/416ms6352 KiB
17Accepted4/416ms6512 KiB