19082022-12-09 12:59:34bzsofiaSorozat generáláscpp11Elfogadva 50/5050ms5736 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ÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1872 KiB
2Elfogadva0/046ms4340 KiB
3Elfogadva2/22ms2280 KiB
4Elfogadva2/23ms2720 KiB
5Elfogadva2/23ms2628 KiB
6Elfogadva2/23ms2832 KiB
7Elfogadva2/23ms3100 KiB
8Elfogadva4/44ms3076 KiB
9Elfogadva4/48ms3556 KiB
10Elfogadva4/412ms4280 KiB
11Elfogadva4/49ms4596 KiB
12Elfogadva4/423ms5372 KiB
13Elfogadva4/428ms5668 KiB
14Elfogadva4/439ms5736 KiB
15Elfogadva4/420ms5572 KiB
16Elfogadva4/450ms5668 KiB
17Elfogadva4/450ms5700 KiB