1605 2022. 11. 28 20:37:19 kicsiboglar Sorozat generálás cpp11 Elfogadva 50/50 3ms 4312 KiB
#include <iostream>
#include <deque>
#include <map>

#define ll long long 

using namespace std;

ll m, a, b, first, n, l, i, j, t, nr,ft,st;
map<ll, ll> x;
deque <ll> v;
int main()
{
    cin >> m >> first >> a >> b >> n >> l;
    bool ok = true;
    ft = 1;
    st = 1;
    for (i = 1; i <= 3 * m; ++i) ft *= 10;
    for (i = 1; i <=m; ++i) st *= 10;

    ll db = 0;
    while (ok)
    {
        db++;
        nr = a * first + b;
        v.clear();
        while (nr > 0)
        {
            v.push_front(nr % 10);
            nr = nr / 10;
        }
        nr = 0;
        while (v.size() < (4 * m)) v.push_front(0);
        for (i = m; i < 3 * m; ++i) { nr *= 10, nr += v[i]; }
       // cout << nr << " ";
        if (x[nr] == 0) x[nr] = db;
        else
        {
            t = db - x[nr];
            cout << db - x[nr] << "\n";
            ok = false;
            break;
        }
        first = nr;
    }


    n -= x[nr] - 1;
    ft = n / t;
    st = n % t;
    ll act = 0;
    map<ll, ll>::iterator e;
    e = x.end();

    while(e!=x.begin())
    {
        --e;
        if (e->second< x[nr]) 
        {
            act += 1;
            if (act == l)
            {
                cout << e->first;
                return 0;
            }
        }
        else
        {
            act += ft;
            if (l <= act)
            {
                cout << e->first;
                return 0;
            }
            if (e->second < x[nr] + st)
            {
                act++;
                if (l <= act)
                {
                    cout << e->first;
                    return 0;
                }
            }

        }
    }
   
}

// 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 1812 KiB
2 Elfogadva 0/0 3ms 2208 KiB
3 Elfogadva 2/2 2ms 2212 KiB
4 Elfogadva 2/2 2ms 2288 KiB
5 Elfogadva 2/2 2ms 2416 KiB
6 Elfogadva 2/2 2ms 2492 KiB
7 Elfogadva 2/2 2ms 2616 KiB
8 Elfogadva 4/4 2ms 2832 KiB
9 Elfogadva 4/4 2ms 3076 KiB
10 Elfogadva 4/4 2ms 3152 KiB
11 Elfogadva 4/4 2ms 3364 KiB
12 Elfogadva 4/4 2ms 3484 KiB
13 Elfogadva 4/4 3ms 3792 KiB
14 Elfogadva 4/4 3ms 3888 KiB
15 Elfogadva 4/4 3ms 4064 KiB
16 Elfogadva 4/4 3ms 4176 KiB
17 Elfogadva 4/4 3ms 4312 KiB