36562023-03-01 19:18:16nkdorka1212Sorozat generáláscpp17Wrong answer 28/5021ms7340 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";
    cout<<v[k].first<<"\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1684 KiB
2Wrong answer0/021ms4900 KiB
3Partially correct1/23ms2072 KiB
4Partially correct1/24ms2488 KiB
5Partially correct1/23ms2680 KiB
6Partially correct1/23ms2948 KiB
7Accepted2/24ms3152 KiB
8Partially correct2/44ms3400 KiB
9Partially correct2/46ms3760 KiB
10Partially correct2/412ms4888 KiB
11Partially correct2/412ms4968 KiB
12Partially correct2/416ms5748 KiB
13Accepted4/418ms6612 KiB
14Partially correct2/419ms6612 KiB
15Partially correct2/420ms7096 KiB
16Partially correct2/421ms7340 KiB
17Partially correct2/421ms7200 KiB