include iostream include string include queue include cmath include se

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;
int values[10] = {0};
int isPolyndrome(int value)
{
int p = 0;
while(value > 0)
{
values[p] = value % 10;
value /= 10;
p++;
}
p--;
int p2 = 0;
while(p > p2)
{
if(values[p] != values[p2])
return 0;
p--;
p2++;
}
return true;
}
int main()
{
int n = 0;
cin >> n;
int maximum = 0;
int a,b;
for(int i = 1; i < n; ++i)
for(int j = i; j < n; ++j)
if(isPolyndrome(i * j) && maximum < i * j){
maximum = i * j;
a = i;
b = j;
}
cout << a << " " << b;
return 0;
}