1908 2022. 12. 09 12:59:34 bzsofia Sorozat generálás cpp11 Elfogadva 50/50 50ms 5736 KiB
// Rendőrjárőr (patrol).cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

long long a, b, k, n, m, i, szam, j, kezd, tavszam;
string s;
vector <long long> x;
map <long long, long long> mp;

bool comp(long long a, long long b)
{
	return a > b;
}

int main()
{
	cin >> m >> szam >> a >> b >> n >> k;
	long long tav = n;
	for (i = 1; i <= n; ++i)
	{
		szam = szam * a + b;
		s = to_string(szam);
		szam = 0;
		if (s.length() <= 3 * m) kezd = 0;
		else kezd = s.length() - 3 * m;
		
		for (j = kezd; j < s.length() - m; ++j)
		{
			szam = szam * 10 + (s[j]-48);
		}

		if (mp[szam] > 0 && i - mp[szam] < tav)
		{
			tav = i - mp[szam];
		}
		mp[szam] = i;
		x.push_back(szam);
	}

	sort(x.begin(), x.end(), comp);

	cout << tav<< "\n"<<x[k - 1];

	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 1872 KiB
2 Elfogadva 0/0 46ms 4340 KiB
3 Elfogadva 2/2 2ms 2280 KiB
4 Elfogadva 2/2 3ms 2720 KiB
5 Elfogadva 2/2 3ms 2628 KiB
6 Elfogadva 2/2 3ms 2832 KiB
7 Elfogadva 2/2 3ms 3100 KiB
8 Elfogadva 4/4 4ms 3076 KiB
9 Elfogadva 4/4 8ms 3556 KiB
10 Elfogadva 4/4 12ms 4280 KiB
11 Elfogadva 4/4 9ms 4596 KiB
12 Elfogadva 4/4 23ms 5372 KiB
13 Elfogadva 4/4 28ms 5668 KiB
14 Elfogadva 4/4 39ms 5736 KiB
15 Elfogadva 4/4 20ms 5572 KiB
16 Elfogadva 4/4 50ms 5668 KiB
17 Elfogadva 4/4 50ms 5700 KiB