30 lines
535 B
C++
30 lines
535 B
C++
#include <cmath>
|
|
#include <iostream>
|
|
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 << " ";
|
|
}
|
|
}
|