13482022-05-21 18:56:22nkdorka1212Sorozat generáláscpp11Accepted 50/5078ms159704 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int c=1e7;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m,x,a,b,n,k;
    cin>>m>>x>>a>>b>>n>>k;
    vector<int>v(n+1);
    vector<int>volt(c+1,0);
    v[0]=x;
    int mini=LLONG_MAX;
    for(int i=1;i<=n;i++)
    {
        int num=v[i-1]*a+b;
        int tizh=1;
        for(int i=1;i<=m*3;i++)
        {
            tizh*=10;
        }
        num%=tizh;
        tizh=1;
        for(int i=1;i<=m;i++)
        {
            tizh*=10;
        }
        num/=tizh;
        v[i]=num;
        if(volt[num]!=0)
        {
            mini=min(mini,i-volt[num]);
        }else
        {
            volt[num]=i;
        }
    }
    v[0]=0;
    cout<<mini<<'\n';
    sort(v.rbegin(),v.rend());
    cout<<v[k-1]<<'\n';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/078ms157996 KiB
2Accepted0/078ms159572 KiB
3Accepted2/267ms158084 KiB
4Accepted2/263ms158156 KiB
5Accepted2/263ms158080 KiB
6Accepted2/267ms158072 KiB
7Accepted2/264ms158128 KiB
8Accepted4/464ms158124 KiB
9Accepted4/465ms158496 KiB
10Accepted4/467ms158980 KiB
11Accepted4/474ms159008 KiB
12Accepted4/470ms159112 KiB
13Accepted4/472ms159636 KiB
14Accepted4/474ms159608 KiB
15Accepted4/471ms159704 KiB
16Accepted4/474ms159628 KiB
17Accepted4/476ms159684 KiB