126412024-12-27 14:15:14ruffbrigiSorozat generáláscpp17Időlimit túllépés 16/50400ms948 KiB
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int m,x,a,b,n,k,y,y2;
    vector<int> sorozat;
    cin>>m>>x>>a>>b>>n>>k;
    int tizpowm=1;
    for(int i=1;i<=m;i++){
        tizpowm*=10;
    }
   // cout<<"10^"<<m<<"="<<tizpowm<<endl;
    for(int i=0;i<=n-1;i++)
    {
        y=x*a+b;
        y2=y;
        int szam=0,h=1;
        szam=y/tizpowm;
        string str=to_string(szam);
        if(str.size()>2*m){
            string substr = str.substr(str.size()-2*m, 2*m);
            szam=stoi(substr);
        }


/*        vector<int> tag;
        for(int j=0;j<=4*m-1;j++)
        {
           tag.insert(tag.begin(), (y2%10));
           y2=y2/10;
        }
        for(int k=0;k<=m-1;k++)
        {
            tag.pop_back();
            tag.erase(tag.begin());
        }
        for(int l=0;l<=2*m-1;l++)
        {
            szam=szam+h*(tag.back());
            h=h*10;
            tag.pop_back();
        }*/
        sorozat.push_back(szam);
      //  cout<<szam<<" ";
        //tag.clear();
        x=szam;
    }
    map<int,int> sorrend;
    int dik=1,p,u;
    bool megvan=false;
    for(int u=0;u<=n-1;u++)
    {
        auto it = sorrend.find(sorozat[u]);
        if (it != sorrend.end()) {
            sorrend[sorozat[u]]++;
        }
        else{
            sorrend[sorozat[u]]=1;
        }
    }
    int w=0;
    for (const auto& pair : sorrend)
    {
        w+=pair.second;
        if(w>=k+1)
        {
            p=pair.first;
            break;
        }
    }
    int mind=n;
    for(int i=0;i<=n-1;i++)
    {
        int target=sorozat.front();
        sorozat.erase(sorozat.begin());
        auto it=find(sorozat.begin(),sorozat.end(),target);
        if (it != sorozat.end()) {
            if(distance(sorozat.begin(), it)<mind)
                mind=distance(sorozat.begin(), it);
    }
    }
    cout<<mind+1<<endl;
    cout<<p;
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base16/50
1Elfogadva0/01ms320 KiB
2Időlimit túllépés0/0381ms948 KiB
3Részben helyes1/21ms512 KiB
4Részben helyes1/22ms320 KiB
5Részben helyes1/22ms320 KiB
6Részben helyes1/21ms320 KiB
7Elfogadva2/23ms320 KiB
8Részben helyes2/44ms468 KiB
9Részben helyes2/427ms568 KiB
10Részben helyes2/4150ms732 KiB
11Részben helyes2/4144ms692 KiB
12Részben helyes2/4280ms948 KiB
13Időlimit túllépés0/4384ms948 KiB
14Időlimit túllépés0/4400ms948 KiB
15Időlimit túllépés0/4382ms948 KiB
16Időlimit túllépés0/4400ms948 KiB
17Időlimit túllépés0/4386ms948 KiB