34322023-02-27 15:04:40norbertvidaSorozat generáláscpp17Partially correct 49/5046ms5752 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;
    lli kulonbseg = N + 1;
    int i;
    for(i = 1; i <= N; i++) {
        X = (((X * A) + B) / tiz_m) % tiz_2m;
        adatok.push_back(X);
        if(utolso.count(X)) {
            kulonbseg = min(kulonbseg, i - utolso[X]);
        }
        utolso[X] = i;
    }
    cout << kulonbseg << "\n";
    sort(adatok.rbegin(), adatok.rend());
    cout << adatok[K - 1] << "\n";
}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/03ms1888 KiB
2Accepted0/041ms4236 KiB
3Partially correct1/23ms2244 KiB
4Accepted2/23ms2688 KiB
5Accepted2/23ms2928 KiB
6Accepted2/23ms3136 KiB
7Accepted2/23ms3244 KiB
8Accepted4/44ms3232 KiB
9Accepted4/48ms3644 KiB
10Accepted4/48ms4260 KiB
11Accepted4/48ms4280 KiB
12Accepted4/418ms5196 KiB
13Accepted4/417ms5592 KiB
14Accepted4/435ms5744 KiB
15Accepted4/416ms5576 KiB
16Accepted4/445ms5672 KiB
17Accepted4/446ms5752 KiB