33212023-02-25 12:47:47gkataSorozat generáláscpp17Wrong answer 28/5021ms22320 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,h1,h2,tav,i,l;

int main()
{
    cin>>m>>kezd>>a>>b>>n>>l;
    h1=hatvany(10,m);
    h2=hatvany(10,2*m);
    y.resize(h2);

    sz=kezd;
    for(i=1;i<=n;++i)
    {
        sz=sz*a + b;
        sz=sz/h1;
        sz=sz%h2;
        x.push_back(sz);
    }
    //for(auto &e:x) cout<<e<<" ";
    //cout<<"\n";

    for(i=0;i<x.size();++i)
    {
        if(!y[x[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<<" ";
    cout<<tav<<"\n"<<x[l+1];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms2020 KiB
2Wrong answer0/019ms19956 KiB
3Partially correct1/23ms2392 KiB
4Partially correct1/23ms2832 KiB
5Partially correct1/23ms2948 KiB
6Partially correct1/23ms3164 KiB
7Accepted2/23ms3448 KiB
8Partially correct2/44ms3840 KiB
9Partially correct2/44ms4424 KiB
10Partially correct2/48ms4848 KiB
11Partially correct2/48ms4848 KiB
12Partially correct2/410ms6000 KiB
13Accepted4/418ms21508 KiB
14Partially correct2/419ms21760 KiB
15Partially correct2/417ms21972 KiB
16Partially correct2/421ms22060 KiB
17Partially correct2/420ms22320 KiB