36582023-03-01 19:24:03nkdorka1212Sorozat generáláscpp17Accepted 50/5021ms6992 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main()
{
    int m,x,a,b,n,k;
    cin>>m>>x>>a>>b>>n>>k;
    vector<pair<int,int>>v(n+1,{0,0});
    v[0].first=x;
    v[0].second=0;
    int tizh=1;
    for(int i=1;i<=m;i++)
    {
        tizh*=10;
    }
    for(int i=1;i<=n;i++)
    {
        int num=v[i-1].first*a+b;
        num/=tizh;
        num%=(tizh*tizh);
        v[i].first=num;
        v[i].second=i;
    }
    v[0].first=INT_MAX;
    sort(v.begin(),v.end());
    int mini=INT_MAX;
    for(int i=0;i<=n-2;i++)
    {
        if(v[i+1].first==v[i].first)
        {
            mini=min(mini, v[i+1].second-v[i].second);
        }
    }
    cout<<mini<<"\n";
    v.pop_back();
    reverse(v.begin(),v.end());
    cout<<v[k-1].first<<"\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/021ms5096 KiB
3Accepted2/23ms2276 KiB
4Accepted2/23ms2688 KiB
5Accepted2/23ms2900 KiB
6Accepted2/23ms3080 KiB
7Accepted2/24ms3316 KiB
8Accepted4/44ms3436 KiB
9Accepted4/46ms3748 KiB
10Accepted4/410ms4708 KiB
11Accepted4/412ms4836 KiB
12Accepted4/414ms5444 KiB
13Accepted4/418ms6484 KiB
14Accepted4/419ms6564 KiB
15Accepted4/420ms6976 KiB
16Accepted4/420ms6924 KiB
17Accepted4/420ms6992 KiB