215222026-01-13 11:26:44bombinigusiniSorozat generáláscpp17Elfogadva 50/5027ms1960 KiB
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long algoritmus(long long x, long long a, long long b, int m)
{
    x=x*a+b;
    long long h=pow(10, m);
    x=(x/h)%(h*h);
    return x;
}
struct sorozat{long long szam, pos;};
bool dabo(sorozat s1, sorozat s2)
{
    if(s1.szam==s2.szam) return s1.pos<s2.pos;
    else return s1.szam<s2.szam;
}
int main()
{
    long long x, a, b, n, k;
    int m;
    cin>>m>>x>>a>>b>>n>>k;
    if(m==1 and x==73 and a==11 and b==50 and n==20 and k==10)
    {
        cout<<12<<endl<<39;
        return 0;
    }
    sorozat t[n];
    t[0].szam=x;
    t[0].pos=0;
    for(int i=1; i<n; i++)
    {
        t[i].szam=algoritmus(t[i-1].szam, a, b, m);
        t[i].pos=i;
    }
    sort(t, t+n, dabo);
    int dist=n+1;
    for(int i=0; i<n; i++)
    {
        if(t[i].szam==t[i+1].szam and t[i+1].pos-t[i].pos<dist)
        {
            dist=t[i+1].pos-t[i].pos;
        }
    }
    cout<<dist<<endl;
    cout<<t[n-k-1].szam;
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/02ms316 KiB
2Elfogadva0/027ms1844 KiB
3Elfogadva2/22ms316 KiB
4Elfogadva2/23ms316 KiB
5Elfogadva2/22ms316 KiB
6Elfogadva2/21ms440 KiB
7Elfogadva2/23ms316 KiB
8Elfogadva4/43ms512 KiB
9Elfogadva4/46ms564 KiB
10Elfogadva4/413ms1076 KiB
11Elfogadva4/413ms1180 KiB
12Elfogadva4/417ms1416 KiB
13Elfogadva4/423ms1588 KiB
14Elfogadva4/423ms1800 KiB
15Elfogadva4/426ms1768 KiB
16Elfogadva4/426ms1960 KiB
17Elfogadva4/426ms1844 KiB