139092025-01-09 10:04:11csdavidSorozat generáláscpp17Hibás válasz 28/5034ms1332 KiB
#include <iostream>
#include <map>
#include <algorithm>
//#include <fstream>
using namespace std;

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

int main()
{
    //ifstream fin("be2.txt");
    cin >> m >> x >> a >> b >> n >> k;
    long long szamjegyek=0;
    long long tomb[n+1], temp;
    long long c[4*m];
    tomb[0]=x;
    for(int i=1; i<=n; i++){
        szamjegyek=0;
        x=tomb[i-1]*a+b;
        //cout << tomb[i-1] << '\n';
        //cout << x << '\n';
        int j=4*m-1;
        while(x){
            c[j]=x%10;
            x=x/10;
            j--;
        }
        while(j>=0){
            c[j]=0;
            j--;
        }

        //cout << "\n";
        x=0;
        for(j=m; j<m*3; j++){
            x=x*10+c[j];
        }
        tomb[i]=x;
        //cout << x << "\n\n";

    }
    long long mini=1000000000;
    map<long long, long long> mp;
    map<long long, long long>::iterator it;
    for(int i=1; i<=n; i++){
        it=mp.find(tomb[i]);
        if(it==mp.end()){
            mp[tomb[i]]=i;
        }
        else{
            if(i-mp[tomb[i]]<mini){
                mini=i-mp[tomb[i]];
                mp[tomb[i]]=i;
            }
        }
    }
    cout << mini << '\n';
    sort(tomb+1, tomb+n+1);
    /*for(auto& i:tomb){
        cout << i << ' ';
    }*/
    cout << '\n' << tomb[k] << '\n';
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base28/50
1Hibás válasz0/01ms316 KiB
2Hibás válasz0/028ms1076 KiB
3Részben helyes1/21ms508 KiB
4Részben helyes1/21ms316 KiB
5Részben helyes1/21ms508 KiB
6Részben helyes1/21ms316 KiB
7Elfogadva2/21ms500 KiB
8Részben helyes2/42ms476 KiB
9Részben helyes2/44ms564 KiB
10Részben helyes2/48ms820 KiB
11Részben helyes2/47ms568 KiB
12Részben helyes2/49ms820 KiB
13Elfogadva4/414ms1224 KiB
14Részben helyes2/424ms1228 KiB
15Részben helyes2/416ms1276 KiB
16Részben helyes2/432ms1304 KiB
17Részben helyes2/434ms1332 KiB