125292024-12-21 15:16:02KissCsongor777Sorozat generáláscpp17Partially correct 49/50127ms1024 KiB
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int m,a,b,n,k;
    long long p,q,r,x;
    cin>>m>>x>>a>>b>>n>>k;
    p=pow(10,4*m-1);q=pow(10,2*m);r=pow(10,m);
    vector<int>h;
    h.push_back(x);
    vector<int>::iterator c;
    bool van=false;
    for(int i=1; i<=n-1; i++)
    {
        x=a*x+b;
        if(x<p)x=p+x;
        x=x/r;
        x=x%q;

        c=find(h.begin(),h.end(),x);
        if(c!=h.end() && !van ){cout<<i-distance(h.begin(),c)<<endl; van=true;}
        h.push_back(x);
    }
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    cout<<h[k-1]<<endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/01ms320 KiB
2Accepted0/063ms1024 KiB
3Partially correct1/21ms320 KiB
4Accepted2/21ms508 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted4/43ms320 KiB
9Accepted4/46ms568 KiB
10Accepted4/418ms824 KiB
11Accepted4/413ms732 KiB
12Accepted4/418ms956 KiB
13Accepted4/4115ms908 KiB
14Accepted4/4108ms900 KiB
15Accepted4/4100ms820 KiB
16Accepted4/4108ms932 KiB
17Accepted4/4127ms948 KiB