225082026-01-15 10:14:21badamSorozat generáláscpp17Wrong answer 24/5025ms1572 KiB
#include <bits/stdc++.h>

using namespace std;
struct szam{int ertek, sorszam;};
bool h(szam a, szam b)
{   if(a.ertek==b.ertek) return a.sorszam<b.sorszam;
    else return a.ertek<b.ertek;
}
int main()
{
    int M, curr, A, B, N, K;
    cin >> M >> curr >> A >> B >> N >> K;
    int v[N];
    for(int i=0;i<N;i++)
    {
        int x=A*curr+B;
        int y=pow(10,3*M);
        int z=pow(10,M);
        x=x%y;
        x=x/z;
        v[i]=x;
        curr=x;
    }
    szam t[N];
    for(int i=0;i<N;i++)
    {
        t[i].ertek=v[i];
        t[i].sorszam=i;
    }
    sort(t,t+N,h);
    int  min_tavolsag=2000000, curr_tavolsag;
    for(int i=1;i<N;i++)
    {
        if(t[i].ertek==t[i-1].ertek)
        {
            curr_tavolsag=abs(t[i].sorszam-t[i-1].sorszam);
        }
        if(curr_tavolsag<min_tavolsag) min_tavolsag=curr_tavolsag;
    }
    cout << min_tavolsag << endl;
    cout << t[N-K].ertek;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/025ms1332 KiB
3Accepted2/21ms508 KiB
4Accepted2/22ms316 KiB
5Accepted2/22ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/23ms316 KiB
8Partially correct2/43ms508 KiB
9Accepted4/44ms416 KiB
10Accepted4/412ms980 KiB
11Partially correct2/412ms980 KiB
12Partially correct2/417ms1212 KiB
13Wrong answer0/421ms1452 KiB
14Wrong answer0/423ms1460 KiB
15Wrong answer0/425ms1564 KiB
16Wrong answer0/425ms1572 KiB
17Wrong answer0/425ms1568 KiB