76062024-01-10 08:38:28gkataSorozat generáláscpp17Accepted 50/5018ms5620 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
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1752 KiB
2Accepted0/018ms4184 KiB
3Accepted2/23ms2132 KiB
4Accepted2/23ms2712 KiB
5Accepted2/23ms2744 KiB
6Accepted2/23ms2820 KiB
7Accepted2/23ms3124 KiB
8Accepted4/44ms3128 KiB
9Accepted4/46ms3588 KiB
10Accepted4/49ms3992 KiB
11Accepted4/48ms3984 KiB
12Accepted4/413ms5024 KiB
13Accepted4/416ms5372 KiB
14Accepted4/417ms5508 KiB
15Accepted4/417ms5288 KiB
16Accepted4/418ms5456 KiB
17Accepted4/418ms5620 KiB