7606 2024. 01. 10 08:38:28 gkata Sorozat generálás cpp17 Elfogadva 50/50 18ms 5620 KiB
// sorozat generalas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include<map>
#include<math.h>
#include <algorithm>
#define ll long long

using namespace std;

vector<ll>x;
map<ll, ll>sz;
ll m, szam, a, b, l, k, t, i, ans;
bool ok = false;

int main()
{
    cin >> m >> szam >> a >> b >> l >> k;

    for(i=1;i<=l;++i)
    {
        szam = szam * a + b;
        t = pow(10, 3 * m );
        szam = szam % t;
        szam /= pow(10, m);
        x.push_back(szam);

        if (!ok)
        {
            if (!sz.count(szam)) sz[szam] = i;
            else
            {
                ans = i - sz[szam];
                ok = true;
            }
        }
    }

    sort(x.begin(), x.end());
    cout << ans << "\n" << x[l - k];
}

/*
1 73 11 50 20 10 
*/

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Részfeladat Összpont Teszt Verdikt Idő Memória
base 50/50
1 Elfogadva 0/0 3ms 1752 KiB
2 Elfogadva 0/0 18ms 4184 KiB
3 Elfogadva 2/2 3ms 2132 KiB
4 Elfogadva 2/2 3ms 2712 KiB
5 Elfogadva 2/2 3ms 2744 KiB
6 Elfogadva 2/2 3ms 2820 KiB
7 Elfogadva 2/2 3ms 3124 KiB
8 Elfogadva 4/4 4ms 3128 KiB
9 Elfogadva 4/4 6ms 3588 KiB
10 Elfogadva 4/4 9ms 3992 KiB
11 Elfogadva 4/4 8ms 3984 KiB
12 Elfogadva 4/4 13ms 5024 KiB
13 Elfogadva 4/4 16ms 5372 KiB
14 Elfogadva 4/4 17ms 5508 KiB
15 Elfogadva 4/4 17ms 5288 KiB
16 Elfogadva 4/4 18ms 5456 KiB
17 Elfogadva 4/4 18ms 5620 KiB