205842026-01-07 18:31:49ZsoltSorozat generáláscpp17Wrong answer 30/5017ms948 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int m,x,a,b,n,k;
    cin>>m>>x>>a>>b>>n>>k;
    vector<int>v(n+1);
    unordered_map<int,int>tav;
    int hat=1;
    for(int i=0; i<m; i++)
    {
        hat*=10;
    }
    int mintav=INT_MAX;
    for(int i=1; i<=n; i++)
    {
        x=x*a+b;
        x=(x/hat)%(hat*hat);
        v[i]=x;
        if(tav.count(x))
        {
            if(mintav>i-tav[x])
            {
                mintav=i-tav[x];
            }
        }
        tav[x]=i;
    }
    sort(v.begin()+1,v.end());
    cout<<mintav<<endl;
    cout<<v[n-k+1];
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/01ms316 KiB
2Wrong answer0/017ms948 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms420 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted4/42ms316 KiB
9Accepted4/44ms316 KiB
10Accepted4/47ms572 KiB
11Accepted4/47ms628 KiB
12Accepted4/49ms704 KiB
13Wrong answer0/414ms780 KiB
14Wrong answer0/414ms820 KiB
15Wrong answer0/412ms868 KiB
16Wrong answer0/414ms872 KiB
17Wrong answer0/417ms872 KiB