#include #include using namespace std; string dec2oct(int dec) { string buffer; while (dec) { buffer = char(dec % 8 + '0') + buffer; dec /= 8; } return buffer; } bool is_palindrome_number(string val) { string reversed; for (int i = val.size() - 1; i >= 0; i--) reversed += val[i]; return reversed == val; } int main() { int n; cin >> n; int sqaure_n = sqrt(n); for (int i = 1; i <= sqaure_n; i++) { if (is_palindrome_number(dec2oct(i * i))) cout << i * i << " "; } }