63572023-11-23 19:55:18MrChipserSorozat generáláscpp11Wrong answer 6/50247ms31936 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];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/03ms1808 KiB
2Wrong answer0/092ms25936 KiB
3Partially correct1/23ms2124 KiB
4Partially correct1/24ms2512 KiB
5Partially correct1/24ms2732 KiB
6Partially correct1/23ms2784 KiB
7Accepted2/24ms3168 KiB
8Wrong answer0/46ms3332 KiB
9Wrong answer0/416ms3560 KiB
10Wrong answer0/420ms4288 KiB
11Wrong answer0/423ms4264 KiB
12Wrong answer0/427ms4604 KiB
13Wrong answer0/4247ms31936 KiB
14Wrong answer0/4137ms27056 KiB
15Wrong answer0/492ms24076 KiB
16Wrong answer0/4101ms29404 KiB
17Wrong answer0/489ms24424 KiB