124402024-12-17 22:07:08szasztundeZenehallgatáscpp17Wrong answer 0/503ms512 KiB
#include <iostream>

using namespace std;
int t[1000000]={0},p[1000000]={0};
int main()
{
    int m,x,n,k;
    long long a,b,ism=0,max=0;
    cin>>m>>x>>a>>b>>n>>k;
    for(int i=1;i<=n;i++)
    {
        long long y=x*a+b,z=0,h=1;
        for(int j=1;j<=m;j++) y=y/10;
        for(int j=1;j<=2*m;j++) h=h*10;
        z=y%h;
        if(z>max) max=z;
        t[z]++;
        if(p[z]==0) p[z]=i;
        else if (ism==0) ism=i-p[z];
        x=z;
    }
    cout<<ism<<endl;
    int db=0,i=max;
    while(db<k)
    {
        if(t[i]>0)
        {
            db++; t[i]--;
        }
        else i--;
    }
    cout<<i;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms320 KiB
2Runtime error0/02ms508 KiB
3Runtime error0/21ms508 KiB
4Runtime error0/21ms408 KiB
5Runtime error0/21ms320 KiB
6Runtime error0/31ms508 KiB
7Runtime error0/31ms320 KiB
8Runtime error0/31ms500 KiB
9Runtime error0/21ms320 KiB
10Runtime error0/21ms320 KiB
11Runtime error0/22ms320 KiB
12Runtime error0/21ms320 KiB
13Runtime error0/21ms320 KiB
14Runtime error0/21ms320 KiB
15Runtime error0/22ms508 KiB
16Runtime error0/21ms320 KiB
17Runtime error0/21ms320 KiB
18Runtime error0/22ms320 KiB
19Runtime error0/21ms444 KiB
20Runtime error0/21ms320 KiB
21Runtime error0/21ms368 KiB
22Runtime error0/32ms512 KiB
23Runtime error0/31ms320 KiB
24Runtime error0/31ms320 KiB