126312024-12-27 12:33:20ruffbrigiSorozat 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;
    for(int i=0;i<=n-1;i++)
    {
        y=x*a+b;
        y2=y;
        int szam=0,h=1;
        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);
        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/0382ms948 KiB
3Részben helyes1/21ms320 KiB
4Részben helyes1/23ms320 KiB
5Részben helyes1/22ms320 KiB
6Részben helyes1/22ms320 KiB
7Elfogadva2/24ms320 KiB
8Részben helyes2/44ms320 KiB
9Részben helyes2/430ms764 KiB
10Részben helyes2/4158ms692 KiB
11Részben helyes2/4150ms776 KiB
12Részben helyes2/4296ms948 KiB
13Időlimit túllépés0/4388ms948 KiB
14Időlimit túllépés0/4400ms948 KiB
15Időlimit túllépés0/4388ms948 KiB
16Időlimit túllépés0/4400ms944 KiB
17Időlimit túllépés0/4382ms948 KiB