#include <iostream>
#include <string>
#include <chrono>
#include <thread>
using namespace std;
bool czyPalindron(string s);
void sprawdzLiczby(unsigned init, unsigned off);
static const unsigned long long int DO_ILU = 1e8; //18446744073709551614; (1.84e19)
int main()
{
auto start = chrono::high_resolution_clock::now();
thread t1(sprawdzLiczby, 1, 4);
thread t2(sprawdzLiczby, 2, 4);
thread t3(sprawdzLiczby, 3, 4);
thread t4(sprawdzLiczby, 4, 4);
t1.join();
t2.join();
t3.join();
t4.join();
auto end = chrono::high_resolution_clock::now();
cout << "Czas: " << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
return 0;
}
bool czyPalindron(string s)
{
for (auto p = s.begin(), k = s.end() - 1; p != k && p < k; p++, k--)
{
if (*p != *k)
{
return 0;
}
}
return 1;
}
void sprawdzLiczby(unsigned init, unsigned off)
{
for (; init <= DO_ILU; init += off)
{
if (czyPalindron(to_string(init)))
{
cout << init << endl;
}
}
}