40 lines
701 B
C++
40 lines
701 B
C++
#include<iostream>
|
|
#include<sstream>
|
|
using namespace std;
|
|
|
|
// bool is_pf(int n){
|
|
// int a = sqrt(n);
|
|
// if(a*a==n){
|
|
// return true;
|
|
// }else{
|
|
// return false;
|
|
// }
|
|
// }
|
|
|
|
bool is_huiwen(int n){
|
|
stringstream ss;
|
|
ss<<std::oct<<n;
|
|
string bjz(ss.str());
|
|
int j=bjz.size()-1;
|
|
for(int i=0;i<(int)bjz.size();++i,--j){
|
|
if(bjz[i]!=bjz[j]){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int main(){
|
|
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
|
|
|
int n;
|
|
cin>>n;
|
|
|
|
const int sqrt_n = sqrt(n);
|
|
for(int i=1;i<=sqrt_n;i++){
|
|
if(is_huiwen(i*i)){
|
|
cout<<i*i<<" ";
|
|
}
|
|
}
|
|
cout<<endl;
|
|
} |