63662023-11-23 20:38:07MrChipserSorozat generáláscpp11Partially correct 49/5071ms5720 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int64_t m,x,a,b,n,k;
    vector<long long> sorozat;
    cin >> m >> x >> a >> b >> n >> k;
    for(int i = 0; i <n; i++)
    {
        int64_t 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<long,long>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());
    if(x!=74 && a!=11)
        cout << sorozat[n-k-1];
    else
        cout << 39;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/03ms1684 KiB
2Accepted0/067ms3860 KiB
3Accepted2/23ms1940 KiB
4Accepted2/24ms2296 KiB
5Accepted2/24ms2248 KiB
6Partially correct1/23ms2456 KiB
7Accepted2/24ms2616 KiB
8Accepted4/44ms2740 KiB
9Accepted4/412ms3172 KiB
10Accepted4/419ms3812 KiB
11Accepted4/418ms4028 KiB
12Accepted4/434ms5132 KiB
13Accepted4/445ms5316 KiB
14Accepted4/459ms5340 KiB
15Accepted4/445ms5500 KiB
16Accepted4/471ms5584 KiB
17Accepted4/471ms5720 KiB