63622023-11-23 20:27:09MrChipserSorozat generáláscpp11Wrong answer 16/5075ms5408 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int m,x,a,b,n,k;
    vector<long> sorozat;
    cin >> m >> x >> a >> b >> n >> k;
    for(int i = 0; i <n; i++)
    {
        long long c = x*a+b;
        //cout << c << endl;
        vector<long long>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-m+i];
            szorzo/=10;
        }
        sorozat.push_back(d);
        x=d;
    }
    //for(int i = 0; i < sorozat.size(); i++)
        //cout << sorozat[i] << " ";
    int mintav = n;
    map<int,int>hmap;
    int elozo=0,akt=0;
    for(int i = 0; i <sorozat.size(); i++)
    {
        if(hmap.find(sorozat[i])!=hmap.end())
        {
            akt = i;
            elozo = hmap[sorozat[i]];
            if(akt-elozo < mintav)
                mintav = akt-elozo;
        }
        hmap[sorozat[i]]=i;

    }
    cout << mintav << endl;
    sort(sorozat.begin(),sorozat.end());
    cout << sorozat[k-1];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/50
1Wrong answer0/03ms1960 KiB
2Wrong answer0/075ms4220 KiB
3Partially correct1/23ms2416 KiB
4Partially correct1/24ms2764 KiB
5Partially correct1/24ms2720 KiB
6Partially correct1/23ms2696 KiB
7Accepted2/24ms2972 KiB
8Partially correct2/44ms3008 KiB
9Partially correct2/412ms3616 KiB
10Partially correct2/419ms4080 KiB
11Partially correct2/418ms4140 KiB
12Partially correct2/432ms5168 KiB
13Wrong answer0/452ms5256 KiB
14Wrong answer0/464ms5288 KiB
15Wrong answer0/446ms5408 KiB
16Wrong answer0/461ms5388 KiB
17Wrong answer0/471ms5384 KiB