63582023-11-23 19:56:44MrChipserSorozat generáláscpp11Wrong answer 6/50245ms31664 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int m,x,a,b,n,k;
    vector<int> sorozat;
    cin >> m >> x >> a >> b >> n >> k;
    int y = pow(10,2*m);
    long hany[y+1] = {0};
    //cout << 1;
    for(int i = 0; i <n; i++)
    {
        int c = x*a+b;
        vector<int>akt;
        //cout << c << endl;
        while(c!=0)
        {
            akt.insert(akt.begin(),c%10);
            c/=10;
        }
        if(akt.size()!=4*m)
        {
            while(akt.size()!=4*m)
                akt.insert(akt.begin(),0);
        }
        int d=0;
        int szorzo = pow(10,2*m-1);
        for(int i = 0; i < 2*m; i++)
        {
            d+=szorzo*akt[4*m-2*m-1+i];
            szorzo/=10;
        }
        sorozat.push_back(d);
        x=d;
        hany[d]++;
    }
    //for(int i = 0; i < sorozat.size(); i++)
        //cout << sorozat[i] << " ";
    int mintav = n;
    for(int i = 0; i < pow(10,2*m)+1; i++)
    {
        if(hany[i]!=0)
        {
            int kezd = -1;
            int veg = -1;
            for(int j = 0; j < sorozat.size(); j++)
            {
                if(kezd==-1 && sorozat[j]==i)
                    kezd = j;
                else if(kezd!=-1 && sorozat[j]==i)
                {
                    veg = j;
                    break;
                }
            }
            //cout << kezd << " " << veg << endl;
            if(mintav > veg-kezd && kezd!=-1 && veg!=-1)
                mintav = veg-kezd;
        }
    }
    cout << mintav << endl;
    sort(sorozat.begin(),sorozat.end());
    cout << sorozat[k-1];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/03ms1816 KiB
2Wrong answer0/094ms25900 KiB
3Partially correct1/23ms2488 KiB
4Partially correct1/24ms2644 KiB
5Partially correct1/24ms2856 KiB
6Partially correct1/23ms3020 KiB
7Accepted2/24ms3400 KiB
8Wrong answer0/46ms3556 KiB
9Wrong answer0/416ms3912 KiB
10Wrong answer0/420ms4044 KiB
11Wrong answer0/423ms4044 KiB
12Wrong answer0/427ms4560 KiB
13Wrong answer0/4245ms31664 KiB
14Wrong answer0/4138ms27236 KiB
15Wrong answer0/492ms23964 KiB
16Wrong answer0/4100ms29560 KiB
17Wrong answer0/489ms24696 KiB