You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
477 B

#include <bits/stdc++.h>
using namespace std;
bool is_octal_palindrome(int n) {
string s1 = "";
while (n) {
s1 += to_string(n % 8);
n /= 8;
}
string s2 = s1;
reverse(s2.begin(), s2.end());
return s1 == s2;
}
int main() {
int n;
cin >> n;
int s = (int)sqrt(n);
for (int i = 1; i <= s; i++) {
int s2 = i * i;
if (is_octal_palindrome(s2)) cout << s2 << " ";
}
return 0;
}