33192023-02-25 12:32:28gkataSorozat generáláscpp17Runtime error 3/5020ms22048 KiB
#include <iostream>
//#include <fstream>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

//ifstream cin("gen.in");
//ofstream cout("gen.out");

ll k;
ll hatvany(int a,int b)
{
    if(b==0) return 1;
    else k=hatvany(a,b/2);
        if(b%2==0) return k*k;
            else return k*k*a;
}

vector<ll>x;
vector<ll>y;
ll m,kezd,a,b,n,sz,sz1,sz2,sz3,h,s,s2,l,r,h1,kt,h2,tav,i,c;

int main()
{
    cin>>m>>kezd>>a>>b>>n>>l;
    h1=hatvany(10,m);
    h2=hatvany(10,2*m);
    y.resize(h2);
    while(n)
    {
        s=0;
        sz=kezd*a+b;
        sz1=sz;
        r=m;
        while(sz>0)
        {
            sz=sz/10;
            ++s;
        }
        if(s==2*m) sz2=sz1/h1;
        else if(s<(4*m))
        {
            while(r)
            {
                sz1=sz1/10;
                --r;
                --s;
            }
            sz2=sz1;
        }
        if(s>(2*m))
        {
            h=hatvany(10,s-1);
            sz3=sz1;
            while(sz3>0)
            {
            sz3=sz3/10;
            ++s2;
            }
            sz2=sz1%h;

            if((s2-1)>2) sz2=sz2/h1;
        }
        kezd=sz2;
        x.push_back(sz2);
        --n;
    }
    //for(auto &e:x) cout<<e<<" ";
    //cout<<"\n";

    for(i=0;i<x.size();++i)
    {
        c=x[i];
        if(!y[i]) y[x[i]]=i;
        else
        {
            tav=i-y[x[i]];
            break;
        }
    }
    //for(auto &e:y) cout<<e<<" ";
    //cout<<"\n";

    sort(x.begin(),x.end());
    //for(auto &e:x) cout<<e<<" ";
    kt=x[k+1];
    cout<<tav<<"\n"<<kt;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base3/50
1Accepted0/03ms1872 KiB
2Runtime error0/017ms19904 KiB
3Wrong answer0/23ms2416 KiB
4Wrong answer0/23ms2892 KiB
5Partially correct1/23ms3068 KiB
6Wrong answer0/23ms3172 KiB
7Accepted2/23ms3328 KiB
8Wrong answer0/43ms3460 KiB
9Wrong answer0/44ms3728 KiB
10Wrong answer0/46ms4484 KiB
11Runtime error0/47ms4752 KiB
12Runtime error0/48ms5944 KiB
13Runtime error0/414ms21652 KiB
14Wrong answer0/414ms21932 KiB
15Wrong answer0/420ms22048 KiB
16Runtime error0/416ms22040 KiB
17Runtime error0/417ms21944 KiB