2020-10-29 13:41:34 +00:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class node {
|
|
|
|
private:
|
|
|
|
char c(int x) {
|
|
|
|
if (0 <= x && x <= 9) {
|
|
|
|
return x + '0';
|
|
|
|
}
|
|
|
|
return x - 10 + 'A';
|
|
|
|
}
|
2022-05-20 01:23:27 +00:00
|
|
|
|
2020-10-29 13:41:34 +00:00
|
|
|
int len;
|
|
|
|
int nums[20];
|
|
|
|
|
|
|
|
public:
|
|
|
|
node() {
|
|
|
|
len = 0;
|
|
|
|
}
|
2022-05-20 01:23:27 +00:00
|
|
|
|
2020-10-29 13:41:34 +00:00
|
|
|
node(int x, int b) {
|
|
|
|
len = 0;
|
|
|
|
while (x) {
|
|
|
|
nums[len] = x % b;
|
|
|
|
x /= b;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int& operator[](int x) {
|
|
|
|
return nums[x];
|
|
|
|
}
|
|
|
|
|
2020-10-29 13:46:17 +00:00
|
|
|
string str() {
|
2020-10-29 13:41:34 +00:00
|
|
|
string s;
|
|
|
|
for (int i = len - 1; i >= 0; i--) {
|
|
|
|
s.push_back(c(nums[i]));
|
|
|
|
}
|
2020-10-29 13:46:17 +00:00
|
|
|
return s;
|
2020-10-29 13:41:34 +00:00
|
|
|
}
|
2022-05-20 01:23:27 +00:00
|
|
|
|
2020-10-29 13:41:34 +00:00
|
|
|
bool check() {
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (nums[i] != nums[len - i - 1]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int b;
|
|
|
|
cin >> b;
|
|
|
|
for (int i = 1; i <= 300; i++) {
|
|
|
|
node t = node(i * i, b);
|
|
|
|
if (t.check()) {
|
2020-10-29 13:46:17 +00:00
|
|
|
cout << node(i, b).str() << ' ' << t.str() << endl;
|
2020-10-29 13:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|