139002025-01-09 09:38:02csdavidSorozat generáláscpp17Wrong answer 16/5039ms832 KiB
#include <iostream>
#include <map>
#include <algorithm>
//#include <fstream>
using namespace std;

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

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

        int i2=0;
        while(j<4*m){
            c[j]=d[i2];
            j++;
            i2++;
        }
        /*for(auto& it:c){
            cout << it << ' ';
        }
        cout << '\n';*/
        /*for(auto& it:c){
            cout << it << ' ';
        }*/
        //cout << '\n';
        for(j=m; j<m*3; j++){
            x=x*10+c[j];
        }
        //cout << x << "\n\n";
        //cout << x << "\n\n";
        tomb[i]=x;
    }
    int mini=1000000000;
    map<int, int> mp;
    map<int, int>::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;
    sort(tomb+1, tomb+n+1);
    cout << '\n' << tomb[k+1] << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/50
1Accepted0/01ms508 KiB
2Wrong answer0/039ms812 KiB
3Partially correct1/21ms316 KiB
4Partially correct1/21ms316 KiB
5Partially correct1/21ms316 KiB
6Partially correct1/21ms316 KiB
7Accepted2/21ms392 KiB
8Partially correct2/42ms316 KiB
9Partially correct2/44ms316 KiB
10Partially correct2/48ms404 KiB
11Partially correct2/48ms604 KiB
12Partially correct2/414ms684 KiB
13Wrong answer0/425ms764 KiB
14Wrong answer0/432ms832 KiB
15Wrong answer0/419ms820 KiB
16Wrong answer0/430ms820 KiB
17Wrong answer0/437ms824 KiB