19072022-12-09 12:58:24bzsofiaSorozat generáláscpp11Compilation error
// 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, tav = LONG_MAX;
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;

	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
Compilation error
exit status 1
main.cpp:12:59: error: 'LONG_MAX' was not declared in this scope
   12 | long long a, b, k, n, m, i, szam, j, kezd, tavszam, tav = LONG_MAX;
      |                                                           ^~~~~~~~
main.cpp:9:1: note: 'LONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    8 | #include <map>
  +++ |+#include <climits>
    9 | 
Exited with error status 1